帮助重新路由到新的“虚拟”网络子文件夹?
我在将页面从 website.com/controller/action 重新路由到 website.com/admin/controller/action 时遇到问题。
我尝试将其添加到 global.asax 中:
routes.MapRoute(
"Admin",
"admin/{controller}/{action}/{id}",
new { controller = "Admin", action = "Index", id = "UrlParameter.Optional" }
);
它有效,但它也重写了我的其他链接,在意想不到的地方添加了“admin”一词。
我的问题与此类似:ASP.NET MVC Routing,需要帮助创建路线
I'm having problems rerouting my pages from website.com/controller/action to website.com/admin/controller/action.
I tried adding this to global.asax:
routes.MapRoute(
"Admin",
"admin/{controller}/{action}/{id}",
new { controller = "Admin", action = "Index", id = "UrlParameter.Optional" }
);
It worked but it also rewrote my other links adding the word "admin" in unintended places.
My problem is similar to this: ASP.NET MVC Routing, Need help creating route
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 MVC 区域解决了这个问题。但区域的问题是您不能简单地将视图和控制器剪切/粘贴到新区域 - 您必须重新创建所有控制器才能使它们再次工作。希望这对某人有帮助。
Solved this using MVC areas. But the problem with areas is that you can not simply cut/paste your views and controllers to the new area - you have to recreate all of the controllers to make them work again. Hope this helps someone.