Skip to content

Publish issue: Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' #23913

@sincovschi

Description

@sincovschi

Static HTML included as partial Throw error on Publish.

Had following code that read /Content/Home/en/*.html
And include it as

`@{
string path = "/wwwroot/Content" + Model;
DirectoryInfo di = new DirectoryInfo("." + path);
FileInfo[] files = di.GetFiles("*.html", SearchOption.AllDirectories);

foreach(FileInfo file in files)
{
    <partial name="~@path/@file.Name" />
}

}`

On debugging environment everything works fine.
On Publish: have the next error:
InvalidOperationException: Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery at line

To Reproduce

https://github.com/Equanimaster/AntiforgeryIssue
Build this project, then Publish to Folder and run on IIS.

Tried fixes

  • Included all sorts of Nugets that has Antiforgery inside.
  • Included all sorts of options related to Antiforgery.dll to be included on Publish.

Found fix

  • To include file content as @Html.Raw(File.ReadAllText("./path/to/file.html"));

Metadata

Metadata

Assignees

Labels

✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions