Skip to content

Error during runtime compilation for Razor views #8416

@brett-1hw

Description

@brett-1hw

REPRO:

  1. Open Visual Studio 2019
  2. Create New ASP.NET CORE Web Application project
  3. Select Web Application (Model-View-Controller) option
  4. Add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
  5. Update ConfigureServices method in Startup.cs:
services.AddMvc().AddRazorRuntimeCompilation();
  1. Start debugging project
  2. Edit Index.cshtml:
@{
    ViewData["Title"] = "Home Page";
}

<div class="text-center">
    <h1 class="display-4">Welcomeeee</h1>
    <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

  1. Refresh page to see changes

EXPECTED:

  • Razor views recompile and display updates in browser

ACTUAL:

  • 500 error displayed: InvalidOperationException: Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery
    image

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: DuplicateResolved as a duplicate of another issuearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions