'.NET 6 returning view not found while it searches in the exact directory it is located in

I am working on a recent migration from a .NET 5 MVC app towards a .NET 6 MVC app with the new minimal hosting model. During this migration time and time again I hit the "View not found" InvalidOperationException. Proof that the view is located in the right map and the program 'searched' for it in that location: the proof

As you can see all the map and file names corospond.

I have followed the migration guide from Microsoft step by step but to no avail. Personally I think something is going wrong with adding in the endpoints but I have tried every single possible option .NET 6 gives me to add in the default controller route.

app.UseEndpoints(endpoints => {
    endpoints.MapDefaultControllerRoute();
    endpoints.MapRazorPages();
});

or this

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

and ofcourse also this

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

but nothing works. I haven't really found any solutions online yet after googling, and this problem just makes it that I'm stuck with the migration. I hope someone can point me in the right direction.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source