开发者

Creating sub-domains for different cities in my ASP.NET MVC App

I'm learning .NET MVC 2开发者_如何学编程 and would like to know how I could go about creating sub-domains for a list of cities that I have stored in a table. It would be nice if they were somehow created dynamically as I add cities to the table.

For Example:

  • seatle.mysite.com
  • calgary.mysite.com
  • orlando.mysite.com

I'd like for it to work in my local "Dev" environment (windows 7, IIS 7) as well as on my live site (shared hosting, unlimited sub-domains).


You'll have to create your subdomains on your DNS. Technically, you could program this into the Application_Start, but you really should figure out what list you will have and then just do the job to create them once. Alternatively, see if your DNS and webhost can do wildcard domains so that *.domainname.com will go to your website.

After you do that, Maarten Balliauw's blog has an article on how to route subdomains: http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜