ViewEngine.FindView does not find view in Razor Class Library
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Describe the bug
When we use `ViewEngine.FindView(ViewContext, "path/inside/rcl", isMainPage: false)`, we don't get success in spite of view being there.
### To Reproduce
- Create a Razor Class Library and create a simple view in it.
- Then create another ASP.NET Core Web App project using the template, and add project reference to RCL
- Try to render HTML conditionally, based on the presence of the view in RCL
[Link to GitHub minimal working example](https://github.com/hosseinitabar/CheckViewExists)
### Exceptions (if any)
There are no exceptions. It just doesn't work.
### Further technical details
- ASP.NET Core version: .NET SDK 3.1.406, Microsoft.NETCore.App 3.1.21
- The IDE (VS) you're running on, and its version: Visual Studio Community Edition 16.11.6
- Include the output of `dotnet --info`:
dotnet --info Output
```
C:\Temp\Git\CheckViewExists>dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.403
Commit: bf9d168ac2
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.403\
Host (useful for support):
Version: 5.0.12
Commit: 7211aa01b3
.NET SDKs installed:
3.1.406 [C:\Program Files\dotnet\sdk]
5.0.203 [C:\Program Files\dotnet\sdk]
5.0.403 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
```
Contributor guide
Assessment
This issue has not been assessed yet.