开发者

in asp.net mvc is it possible to register routes somewhere other than application.Start()

is it possible to create and register routes after Ap开发者_JAVA技巧plication.Start() is called?

let's say have a controller, PersonController. With default routing, URLs could look something like www.site.com/Person/Edit/4, with 'Person' matching the controller.

now imagine I have several users, some may prefer we use the term 'Friends'. I would like to use the same controller, and have /Friends/Edit/4 map to the same controller/action/id. Maybe someone else prefers /Comrades/Edit/4.

with the naming preferences stored in a database, is there a way that I can dynamically create these routes at some point mid-application, after the user has logged in?

thanks!


What about holding the preferences in your config file.

You could then in application start read the config file and apply the routes.

So then when you deploy to a client you can deploy with their config file and if they change their mind deploy another config file.

i guess you could create the routes at anytime but the default one will still need to be done at the start else mvc won't even work i don't think.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜