Asp.net 3.5 SP1子域路由? [英] Asp.net 3.5 Sp1 Sub-Domain routing?
问题描述
我在想,是有办法在Asp.net引入子域3.5路由
I was wondering is there is a way to introduce sub-domains in Asp.net 3.5 routing
所有我发现,因为这 http://blogs.securancy.com /post/ASPNET-MVC-Subdomain-Routing.aspx
但我一直在寻找更复杂的东西,让做外卡子域
But i was looking for something more complex to allow doing wild-card sub-domains
任何帮助吗?
推荐答案
应该没问题,即使该样品。在这种情况下,只需添加一个通配符到DNS* .yourdomain,并使用默认的语句从交换机来处理通配符。
Should be no problem, even with that sample. In this case, just add a wildcard to your DNS "*.yourdomain" and use the 'default' statement from the switch to handle wildcards.
在换句话说,对于在Global.asax样品更改为类似
In other words, change the sample for the Global.asax to something like:
default:
returnValue = new RouteData(this, new MvcRouteHandler());
returnValue.Values.Add("controller", "MyControllerName");
returnValue.Values.Add("action", "MyActionName");
// for example, provide the entered subdomain as parameter;
returnValue.Values.Add("MyActionParameterName", subDomain);
break;
不要忘了:通配符添加到您的DNS。它不应可能测试在本地主机上的子域,虽然。
And don't forget: add a wildcard to your DNS. It shall not be possible to test subdomains on localhost, though.
这篇关于Asp.net 3.5 SP1子域路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!