Get route.name through Httpcontextbase

Asked

Viewed 19 times

0

I have mapped routes in my application:

context.MapRoute("Home.Index", "home/{action}/{parameter}", 
        new { controller = "Home", action = "Index", parameter = UrlParameter.Optional });

I wrote an attribute that you inherit from: AuthorizeAttribute, that memorizes some methods. When executing the attribute method:

protected override bool AuthorizeCore(HttpContextBase httpContext){ }

would like to get the name of route Home.Index through the object: httpContext.

That’s possible?

  • Of course it is not possible. There are alternatives, but I don’t think any are worth it. Why you need the name of the route?

  • @LINQ Because I end up doing a permissions control based on the prefix of the route. This control is dynamic and everything is generated from this: menus, accesses and etc. I needed to know what is the registered route, if any, for the method in question...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.