[英]Asp.net 3.5 Sp1 Sub-Domain routing?
I was wondering is there is a way to introduce sub-domains in Asp.net 3.5 routing 我想知道是否有一种方法可以在Asp.net 3.5路由中引入子域
All i found as this http://blogs.securancy.com/post/ASPNET-MVC-Subdomain-Routing.aspx 我发现的所有内容都是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 但我一直在寻找更复杂的方法来允许使用通配符子域
Any Help ? 有帮助吗?
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.
在这种情况下,只需将通配符添加到您的DNS“ * .yourdomain”中,并使用开关中的'default'语句来处理通配符。
In other words, change the sample for the Global.asax to something like: 换句话说,将Global.asax的示例更改为:
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;
And don't forget: add a wildcard to your DNS. 并且不要忘记:将通配符添加到DNS中。 It shall not be possible to test subdomains on localhost, though.
但是,将不可能在localhost上测试子域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.