MVC 3 URL动态路由

发布于 2024-12-06 08:29:57 字数 495 浏览 3 评论 0原文

你能告诉我如何在 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 技术交流群。

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

发布评论

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

评论(1

且行且努力 2024-12-13 08:29:57

您可以考虑使用 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.

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