Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InvalidOperationException: The view 'Index' was not found. The following locations were searched

The following error occurs when creating a new ASP.NET Core MVC project or loading old projects in .NET 7:

enter image description here

All the archovios are created and in the right place.

enter image description here

The error persists even if you manually change the route

enter image description here

I have searched everywhere and have not been able to find the problem.

like image 434
Samuel Sanchez Avatar asked Dec 10 '25 15:12

Samuel Sanchez


2 Answers

1- Go to your project solution -->Right click and add Nuget Packages called *Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation* install this.

2- Add one line on Program.cs file i.e builder.Services.AddControllersWithViews()***.AddRazorRuntimeCompilation()***;

like image 137
Parth Hadkar Avatar answered Dec 12 '25 12:12

Parth Hadkar


For anyone having this issue when updating to Visual Studio 2022 17.7.7, updating to 17.8 solved it.

like image 22
GreeNSparT Avatar answered Dec 12 '25 10:12

GreeNSparT



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!