How do I solve a “view not found” exception in asp.net core mvc project

前端 未结 16 1984
梦毁少年i
梦毁少年i 2020-12-09 15:53

I\'m trying to create a ASP.NET Core MVC test app running on OSX using VS Code. I\'m getting a \'view not found\' exception when accessing the default Home/index (or any oth

16条回答
  •  被撕碎了的回忆
    2020-12-09 16:08

    I just upgraded from .net core 2.2 to 3. Two ways to resolve I found:

    Either call AddRazorRuntimeCompilation() when configuring mvc, like:

    services.AddControllersWithViews()
        .AddRazorRuntimeCompilation(...);
    

    more info here: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#opt-in-to-runtime-compilation

    Or remove the following lines from the .csproj:

    false
    false
    

提交回复
热议问题