1

First of all, I have read a lot of post relating this issue like: Asp.net MVC RouteBase and IoC , Tenant-specific routes for dynamically loaded modules , and many others.

What I want is: - Dynamically create pages like tenant1.mydomain.com, tenant2.mydomain.com, etc. - My tenants will have the same functionality but just different content, styles, title, etc.

I have tried extending RouteBase class but have read that is not a clean solution. Then I have tried creating a custom RouteConstraint like above posts recommend but not succeded.

Help me!

Thanks!

Community
  • 1
  • 1
gonzalomelov
  • 931
  • 1
  • 11
  • 30
  • you might want to checkout hipache. It does what you are asking for really easily. checkout this answer: http://serverfault.com/a/624877/239954 – AnandKumar Patel Aug 29 '14 at 05:47

1 Answers1

0

I have achieved this by doing two things. 1) was to provide functionality to select the correct content by providing the repositories via a factory which was handed the URL on creation. The issue here is that it might be possible to fetch the wrong data via relationships from entities that themselves don't have a tennantid field.

2) Is a basic custom view engine which looks up the host part of the URL and would look for a client specific template (via a folder structure) if the template was found it was used, otherwise the default template is returned.

Between these two I've got a system that delivers (in my case) multiple websites via the same bespoke CMS and product management tool.

Andiih
  • 11,749
  • 9
  • 54
  • 87
  • thanks for your response! I understand what you say but i'm looking for something more specific, in coding terms. For example, I have extended RouteBase class, specifically the GetRouteData, where I parse the Url and add the subdomain in routeData.Values. Then in some Controller I look in the db for the contents of the tenant and retrive them. But i couldn't make it work yet, because when the url is tenant1.mydomain.com/Controller/Action it doesnt route me to the action specified. – gonzalomelov May 05 '12 at 22:40
  • any clues here ? http://stackoverflow.com/questions/4540768/asp-net-mvc-routebase-and-ioc – Andiih May 05 '12 at 23:14
  • I have read that and couldn't get anything valuable. I'm trying http://lukesampson.com/post/303245177/subdomains-for-a-single-application-with-asp-net-mvc by now. Thanks Andiih!! – gonzalomelov May 06 '12 at 00:03