Asp.net 3.5 Sp1 子域路由?

发布于 2024-07-22 07:37:27 字数 288 浏览 5 评论 0 原文

我想知道是否有一种方法可以在 Asp.net 3.5 路由中引入子域

我发现的所有内容都是这样 http://blogs.securancy.com/post/ASPNET-MVC-Subdomain-Routing.aspx

但我一直在寻找更复杂的东西来允许执行通配符子域

有帮助吗?

I was wondering is there is a way to introduce sub-domains in Asp.net 3.5 routing

All i found as this 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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半步萧音过轻尘 2024-07-29 07:37:27

即使使用该样本,也应该没问题。 在这种情况下,只需向您的 DNS“*.yourdomain”添加通配符,并使用交换机中的“default”语句来处理通配符。

换句话说,将 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;

并且不要忘记:向您的 DNS 添加通配符。 但是,不可能在本地主机上测试子域。

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.

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;

And don't forget: add a wildcard to your DNS. It shall not be possible to test subdomains on localhost, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文