.Net 8 SDK - AddRazorRuntimeCompilation error - Index.cshtml not found
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
We have an .net 6 project that runs MVC, and when we install the .Net 8 SDK on our local machine, and run the project, we get the error:
The view 'Index' was not found. The following locations were searched: /Views/Content/Index.cshtml /Views/Shared/Index.cshtml /Pages/Shared/Index.cshtml
We found that adding
`builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();`
to program.cs
fixes the issue, but this could potentially break multiple sites, if the server running the site gets the .net 8 SDK
### Expected Behavior
_No response_
### Steps To Reproduce
Have an older .net project either 6 or 7 that runs mvc.
Install .net 8 SDK on local machine
Now the compiler cant find the index.cshtml file.
### Exceptions (if any)
The view 'Index' was not found. The following locations were searched: /Views/Content/Index.cshtml /Views/Shared/Index.cshtml /Pages/Shared/Index.cshtml
### .NET Version
.net 6
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.