Home > Software engineering >  Views not found after migrating to .NET 6
Views not found after migrating to .NET 6

Time:02-28

I migrated an ASP.NET CORE MVC project from .NET Core 2.1 to .NET 6.

After making relevant changes, the project compiles and starts seemingly OK, but the views aren't found.

Root path is set app.Environment.ContentRootPath = Directory.GetCurrentDirectory(); and the path to views seems to be correct. This is the error message that follows:

enter image description here

The Login.cshtml is in /Views/Account folder, and Build Action is set to Content.

CodePudding user response:

your account folder maybe missing in areas like enter image description here

if it is ok then in Startup.cs

in this method public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

paste this code

  app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");
            endpoints.MapRazorPages();
        });

CodePudding user response:

Found a solution.

An outdated Razor package messed up the pipeline somehow. I'm not sure why.
Removing the Razor package solved the issue.

  • Related