The view 'Index' was not found
Visual Studio Community 2019 for Mac Version 8.10.19 (build 2)
1- create project Web application MVC (net 5.0) 2- upgrade to Net 6.0 (https://docs.microsoft.com/en-us/aspnet/core/migration/50-to-60?view=aspnetcore-6.0&tabs=visual-studio-mac) 3 - run 4 - Exception Error : fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. System.InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Home/Index.cshtml /Views/Shared/Index.cshtml
API Working fine , Web application MVC not working
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 5bec61f9-7298-170d-5e12-abb27cde584e
- Version Independent ID: 27a43e3f-149d-9058-f937-0eda1d6dd4f2
- Content: Migrate from ASP.NET Core 5.0 to 6.0
- Content Source: aspnetcore/migration/50-to-60.md
- Product: aspnet-core
- Technology: aspnetcore-migration
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
That's a really good error message.
InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Home/Index.cshtml /Views/Shared/Index.cshtml
InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Home/Index.cshtml /Views/Shared/Index.cshtml
Really good error message.
i solved cmd - dotnet watch run :) you helped a lot man :) 🗡️
So what did you do wrong?
i solved cmd - dotnet watch run :)
So I didn't run a dotnet for short.🤣🤣🤣
Without command how we can run project vai IIS express?
I have VS 2019 (v. 16.11.2). Just created a new ASP.NET Core Web MVC application (was targeting to net5.0 by default, but I had to specify net6.0 there). After that, I was getting the same error whenever I launched the project via standard "run IIS express". I noticed, the error goes away if I run its via "dotnet run" command. But it must work from IDE as well..So, the issue still exists actually.
dotnet sdk version (via dotnet --info): 6.0.201
P.S I can't update to VS2022 as my laptop too slow for its.
i was also facing similar issue,took long time to fix... Solution is in .csproj if any views are with Remove then delete those entry and include those views to project in solution explorer... then actual fix is just add one test view viewfile index3.cstml and make it called from action then deploy all works well. Later can remove that extra view file. 100% it works. https://stackoverflow.com/questions/49483693/net-core-2-0-the-view-index-was-not-found/72907896#72907896
Is there any resolution to this error? I am also seeing this even though it tells me it search exactly where the view is located.
An unhandled exception occurred while processing the request.
InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Areas/Fluids/Views/WorkOrderRecon/Index.cshtml
/Areas/Fluids/Views/Shared/Index.cshtml
/Views/Shared/Index.cshtml
/Pages/Shared/Index.cshtml
Endpoint
| Name | Value |
|---|---|
| Display Name | CorporateSite.Web.Controllers.Fluids.WorkOrderReconController.Index (CorporateSite.Web) |
| Route Pattern | Fluids/{controller}/{action=Index}/{id?} |
| Route Order | 1 |
| Route HTTP Method | GET |
Route Values
| Variable | Value |
|---|---|
| action | Index |
| area | Fluids |
| controller | WorkOrderRecon |
I had the same issue because I manually updated my project to .net 6.0 but was still using VS 2019.
At some point, during building, it says that VS 2019 does not support .net 6.0, or something like that.
I had to upgrade to VS 2022.
I had the same issue because I manually updated my project to
.net 6.0but was still using VS 2019.At some point, during building, it says that VS 2019 does not support
.net 6.0, or something like that.I had to upgrade to VS 2022.
Is there any workaround in case upgrading to VS2022 is not possible? I was trying to follow a suggestion from @madhusudhan-v (delete existing .cshtml file and create a new one) but it didn't solve this issue.
I was facing this issue when I upgraded my .net application to .net core 6.0
<TargetFramework>net6.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
this AddRazorSupportForMvc setting helped to resolve this issue of "the-view-index-was-not-found"
I had the same problem. Following @pmadusud-v's tip, I looked at my csproject and saw that he had removed and included my view..
`ItemGroup> -- removed Content Remove="Views\Championships\Login.cshtml" /> -- removed /ItemGroup> -- removed
ItemGroup> --lot of packages /ItemGroup>
ItemGroup> -- removed None Include="Views\Championships\Login.cshtml" /> -- removed /ItemGroup> -- removed
I didn't understand why this was put in my csproject, but I removed it and it worked
This solved it for me https://www.google.com/search?q=The+view+%27Index%27+was+not+found&oq=The+view+%27Index%27+was+not+found&aqs=chrome..69i57j0i19i512l2j0i19i22i30l7.705j0j4&sourceid=chrome&ie=UTF-8#fpstate=ive&vld=cid:8729b706,vid:oQSOnRqHMHs
Have a try adding Nuget
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.22" />
and change a line in Program.cs
builder.Services.AddControllersWithViews();
to
builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
I don't deep dive inside but it helps me.
OR add SDK 6-7 and update VS2022
In my case (core 6) AreaViewLocationFormats did not work correctly. Solution: add a controller tag or method [Area("your_area")] to the controller
This works temporarily in development when you publish to a server, it comes back and the exception appears. Have you resolved this from the root?
That is, installing Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation works but when publishing to ISS the error appears again, is there any definitive solution for both development and production, am I using visual 2022?
For me this error apeared suddenly. The project launched successfully, but on the next try, “index not found.” The problem was in one of the views in the razor syntax. In another cshtml, not in the Index. I started construction '@(' but didn't close it correctly with ')'. In this state, the program compiles and runs, but cannot find its views. Check it out, it might be the same for you. In the view with an error, all html tags after the wrong '@(' will not have highlighting.
essa configuração AddRazorSupportForMvc ajudou a resolver esse problema de "the-view-index-was-not-found"
Thanks, this resolved my case