`IRazorPageFactoryProvider.CreateFactory(relativePath)` should also take absolute paths
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
Currently, `IRazorPageFactoryProvider.CreateFactory(relativePath)` does not work if you pass it an absolute path to a view, like this:
```c#
var razorFactoryProvider = webApp.Services.GetRequiredService();
var viewPath = "c:/dev/MyMvcSolution/MyMvcProject/Views/SomeView.cshtml"; // <-- absolute path
var factoryResult = razorFactoryProvider.CreateFactory(path);
Console.WriteLine($"Success: {factoryResult.Success}"); // Success = false
```
However, if you give it a path that's relative to the project, like this:
```c#
var razorFactoryProvider = webApp.Services.GetRequiredService();
var viewPath = "Views/SomeView.cshtml"; // <-- relative path
var factoryResult = razorFactoryProvider.CreateFactory(path);
Console.WriteLine($"Success: {factoryResult.Success}"); // Success = true
```
It works fine.
Can the `CreateFactory()` method be modified to accept absolute file paths? Historically, `RazorFileSystem` could be used to convert absolute view paths to relative paths, but `RazorFileSystem` has been marked as obsolete in .NET 10. A quick fix for these woes would be to make `IRazorPageFactoryProvider.CreateFactory()` accept absolute paths.
Contributor guide
Assessment
This issue has not been assessed yet.