0

How to assign controller name and action name dynamically in asp.net mvc

2
  • Dynamically to what? when? Give an example Commented Apr 10, 2009 at 11:08
  • Im writing my own route handler ...in that i want to specify action name ...depending upon my requirements Commented Apr 10, 2009 at 11:13

1 Answer 1

1

On HttpApplication.Application_Start your can add dynamically any routes (Controller and Action anme) to RouteTable.Routes, this you can use any information available in this event or ever populate routes from config file or database.
For example

new Route( "Admin/{actionName}/{slug}/", CreateRouteHandler())  
{  
   Defaults = new RouteValueDictionary(defaults),  
   Url = new RouteValueDictionary(dataTokens)  
}

You couldn't change actions in RouteHandler, you could process current HttpRequest in your different ways, for example.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.