Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default .Net 6 MVC Web App Template: The view 'Index' was not found

I created a brand new web app in VS2022 using the "ASP.Net Core Web App (Model-View-Controller)" Template in .Net 6

I ran the application and got this error:

InvalidOperationException: The view 'Index' was not found.

I haven't changed any of the template code.

Very strange...

like image 544
JTech Avatar asked Nov 21 '25 17:11

JTech


1 Answers

I've found one way to get it working...although its not clear to me why this works:

Add this package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation

and then change services.AddControllersWithViews() in Program.cs

builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
like image 87
JTech Avatar answered Nov 24 '25 11:11

JTech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!