-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templates
Description
Currently, IRazorPageFactoryProvider.CreateFactory(relativePath) does not work if you pass it an absolute path to a view, like this:
var razorFactoryProvider = webApp.Services.GetRequiredService<IRazorPageFactoryProvider>();
var viewPath = "c:/dev/MyMvcSolution/MyMvcProject/Views/SomeView.cshtml"; // <-- absolute path
var factoryResult = razorFactoryProvider.CreateFactory(path);
Console.WriteLine($"Success: {factoryResult.Success}"); // Success = falseHowever, if you give it a path that's relative to the project, like this:
var razorFactoryProvider = webApp.Services.GetRequiredService<IRazorPageFactoryProvider>();
var viewPath = "Views/SomeView.cshtml"; // <-- relative path
var factoryResult = razorFactoryProvider.CreateFactory(path);
Console.WriteLine($"Success: {factoryResult.Success}"); // Success = trueIt 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.
Metadata
Metadata
Assignees
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templates