Is there a way to map the Areas within an ASP.NET MVC 2 application to subdomains such as
movies.example.com/Theater/View/2
instead of
example.com/Movies/Theater/View/2
where { area = “Movies”, controller = “Theater”, action = “View”, id = 2 }.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Areas are not directly related to routing, so your question becomes “does routing support subdomains?”
The answer to that is unfortunately that there is no built-in support for this.
However, the good news is that many people have tried and found success with custom code that builds on top of routing:
If you figure out how to route subdomains without areas then doing it with areas should be no more difficult. Go to your area registration context and use whatever technique you choose inside there. Areas are just a way to group together controllers and views – they don’t have very much intrinsic meaning to ASP.NET MVC itself (they do a little bit, but not a lot).