Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement in razor page #14

Open
imtiazahmeddahar opened this issue Jul 27, 2020 · 6 comments
Open

How to implement in razor page #14

imtiazahmeddahar opened this issue Jul 27, 2020 · 6 comments

Comments

@imtiazahmeddahar
Copy link

i have created new MVC core 3.1 application with razor identity. when i run the application and i'm getting this error:

InvalidCastException: Unable to cast object of type 'Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor' to type 'Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor'.
SchoolManagementSystem.ExtentionMethods.DynamicAuthorizationFilter.IsProtectedAction(AuthorizationFilterContext context) in DynamicAuthorizationFilter.cs, line 66

please guide me, how can i implement DynamicRoleBasedAuthorizationNETCore in razor pages as well.

@mo-esmp
Copy link
Owner

mo-esmp commented Jul 27, 2020

At the moment DynamicRoleBasedAuthorizationNETCore only supports MVC not Razor Pages and sorry for that. The main problem is that I cannot figure out how to get a page URL because it's related to the folder structure and I don't have much experience with Razor Pages. I should spend more time on Razor Pages and find out how routing exactly works or if someone can help me with this case.

@imtiazahmeddahar
Copy link
Author

i found filters for razor pages from Microsoft's docs but i don't know how to implement it. Would you like to please review it?

Filter methods for Razor Pages in ASP.NET Core:
[https://docs.microsoft.com/en-us/aspnet/core/razor-pages/filter?view=aspnetcore-3.1]

@mo-esmp
Copy link
Owner

mo-esmp commented Jul 30, 2020

@imtiazahmeddahar Ok sure, I'll guide you on how to implement dynamic auth in Razor Pages.

@shaunVorster
Copy link

Hi mo-esmp. Firstly thanks for the great repo.

I have followed your manual branch implementation in a project I'm using but also ran into the razor page issue as I'm using idenitiy scaffolded pages.

Could you please post your suggestions / guide for implementing the fix for razor pages?

@mo-esmp
Copy link
Owner

mo-esmp commented Jun 23, 2022

Hey @shaunVorster,
Sorry for the late reply. As I mentioned in previous comments, the main problem with Razor Pages for me is routing and couldn't find a solution for that and I haven't worked on it in a long time. For now, my suggestion is to take a look at the MvcControllerDiscovery to find out how it find controller actions and also take a look at this.

@shaunVorster
Copy link

Hey @mo-esmp. Thanks very much for the reply. I will check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants