开发者

ASP.NET Multi tenant route configurations

This is not a question of how to implement multi-tenancy. What I am looking for is the ability to optionally override the default application routes when required.

A simple case is that I have a route that generates a blog url like so:

http://[domain]/blog/post-slug

My configuration is blog/{slug}

However, some tenants do wish to call their blog "news". Although I can change all references blog in their views, I can't do it in the URL.

I would like a simple way of overriding these route configurations without changing the "core" codebase.

One thought I had would be to use named routes and then use this to swap out route configurations when the app starts. I should 开发者_运维知识库add that multiple tenants will not be using the same application instance, just the same codebase.

Thanks, Ben


You can always add a route using a regular expression. There is also a great tool on figuring out what routes to add to get what you want.

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx


What about if you have a filter that detects which type of user is accessing the action. If it is one who wants the word news, you can redirect them to a controller called news - which inherits all the functionality from blog.

I can't say I'm 100% confident, but I think it might work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜