ardalis / ardalis/OrganizingAspNetCore
Handling Razor Pages when mixed with MVC
- Dominant language
- C#
- Stars
- 210
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Description
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?
```csharp
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
```csharp
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?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the controllerActionDescriptor null check shown in the issue and review how Razor Pages expose PageActionDescriptor. Reproduce the exception in a project mixing MVC and Razor Pages, then verify that both action types are handled without failing and that the feature name remains available where applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100