开发者

Registering routes on session start not application start

I am trying to register the route collection in .net based on each session. The code I have works fine, you goto website/username and it loads the correct sub pages, but you have to restart the application to goto website/username2 to load those sub pages. But when the application is restarted the second one works, but then not the first one.

Is there some way to create a different route collection per session not per application using system.web.routin开发者_运维技巧g.


Routes are linked to route names and are stored globally for the web application, so you can't really define routes per session. Can you give an example of why you need different routes for different users? Most likely it can be solved by simply using route patterns, like setting RouteUrl to somehting like : "member/logo/{size}/{UserName}.jpg", where you can specify UserName and size when generating the route url via Page.GetRouteUrl()


You can create your own route handler. Take a look at : ASP.Net MVC Framework - Create your own IRouteHandler.

Using such approach, you will be able to route differently per request. Each request can then take a look at your session values to get the correct handler.


RouteTable.Routes is static so the same routes are shared across all Sessions. So you can't have a different set of routes for each session.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜