Handling Razor Pages when mixed with MVC
Firstly a great library, I've been using your library for a while, and recently with the introduction of ASP.NET 2.1 Identity as a library https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.1&tabs=visual-studio
I noticed that an exception is thrown for Razor Pages
It seems the controller action description is null for razor pages?
if (controllerActionDescriptor == null)
{
throw new NullReferenceException("ControllerActionDescriptor cannot be null.");
}
Am I missing something or should this still be able to work?
UPDATE I was able to solve the issue by using the following line instead
var featureName = controllerActionDescriptor != null ? controllerActionDescriptor.Properties["feature"] as string : string.Empty;
I'm not sure if this is the best way to solve the issue, would be interesting to know how to detect razor controller action
UPDATE2 Looks like **PageActionDescriptor ** can be used to read razor pages https://joonasw.net/view/discovering-actions-and-razor-pages
Further information can be found here: https://github.com/aspnet/Mvc/issues/7796
Maybe this can help in trying to make it better?
Hi @dotnetshadow thanks for the issue and additional research! I'll take a look and see if I can update things to be better. Or, if you're inclined to submit a pull request, I'd be happy to review and accept one for this. Thanks again!