可以将域名作为我的路由规则参数的一部分? [英] Can have part of the domain name as a parameter in my routing rules?

查看:162
本文介绍了可以将域名作为我的路由规则参数的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个接受了我的域名的一部分作为参数路由规则。例如:

I'd like to have a routing rule that accepted part of my domain name as a parameter. For example:

{name}.mydomain.com/photos/{id}

这甚至可能吗?

推荐答案

我曾在使用asp.net mvc的一个类似的问题,而是使用整个域,而不是仅仅的子域。我们使用的是一个自定义路由约束决定去(在我们的项目域控制器确定)的控制器。然后在控制我们用正常的asp.net request.url属性来采取行动。这可能会或可能不会根据您的具体要求提供帮助。

I have had a similar issue in using asp.net mvc, but with using the whole domain instead of just the subdomain. What we used was a custom route constraint to determine which controller to go to (domain determined controller on our project). Then in the controller we used the normal asp.net request.url properties to take an action. This may or may not help depending on your exact requirements.

这篇关于可以将域名作为我的路由规则参数的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆