I need my web site to catch URLs like mysite.com
and a.mysite.com
as the same. By another words, requests to these URLs should be handled by single action controller and user should catch the same response from them.
Thanks in advance.
Asked
Active
Viewed 137 times
2

Sergey Metlov
- 25,747
- 28
- 93
- 153
2 Answers
1
Have you looked into Controllers and Routing?

Jamie Hutton
- 260
- 3
- 13
-
As far as I know MVC routing can't help to set up such "cross-subdomain" mapping. – Sergey Metlov Dec 18 '11 at 22:17
-
you could use something like [subdomain-routing](http://stackoverflow.com/questions/278668/is-it-possible-to-make-an-asp-net-mvc-route-based-on-a-subdomain) and check the current url to generate the subdomain name based on that, just send it to the same place. – Jamie Hutton Dec 18 '11 at 22:26
1
MVC won't help you here--other than defining the default controller and action (route) when browsing to a site.
You will need to catch these hostname in your hosting environment. In IIS, I think you can use wildcards when creating a website. In your case, it would probably look like:
*.mysite.com
Your application would live inside this site, and anyone accessing it on an unexpected subdomain would see the same thing.

David Fox
- 10,603
- 9
- 50
- 80
-
-
1Not to my knowledge. Jamie Hutton's comment about subdomain-routing might be what you're looking for if you have to do it programmatically. Though, I would still do it at the host level. – David Fox Dec 19 '11 at 13:53