MVC 3 URL动态路由
你能告诉我如何在 MVC 中做到这一点
我有 2 个站点使用完全相同的生产流程,但有些不同
结构如下: 域名.com
----站点1
----站点2
我怎样才能设置这样的网址
http://domain.com/Site1/controller1/action1
它将转到控制器:site1_controller1 - 操作:action1
http://domain.com/Site2/controller1/action1< /a>
它将转到控制器:site2_controller1 - 操作:action1
或者在这种情况下可以使用任何好的方法。
非常感谢
Can you show me how to do that in MVC
I have 2 sites use the whole same Producing process, but some are different
Struct like:
domain.com
----Site1
----Site2
How can I setup the url like this
http://domain.com/Site1/controller1/action1
it will go to controller: site1_controller1 - action: action1
http://domain.com/Site2/controller1/action1
it will go to controller: site2_controller1 - action: action1
Or any good method can be used in this case.
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以考虑使用 MVC 区域而不是使用串联的控制器名称。区域只是一组控制器,因此您可以有一个名为 Site1 的区域,其中包含一个名为controller1 的控制器,然后在名为 Site2 的区域内有一个单独的controller2。
请参阅 http://msdn.microsoft.com/en-us/library/ee671793。 aspx 进行演练。
You could consider using MVC areas instead of having a concatenated controller name. An area is just a group of controllers, so you could have an area called Site1 with a controller called controller1 inside it, and then a separate controller2 inside an area called Site2.
See http://msdn.microsoft.com/en-us/library/ee671793.aspx for a walkthrough.