特殊区域路由(ASP.NET MVC)
我在 ASP.NET MVC3 路由方面遇到了一个不寻常的问题。我创建了一个名为“帐户”的区域,并在其中创建了一个带有“登录”操作的控制器“主”。现在我想创建一条路线,看起来像这样:“/Login”(这意味着没有“/Account/Main/Login”),但我一直未能做到这一点(我已经使用了 AccountAreaRegistration< /code> 来注册路由,但是
@Html.ActionLink
总是跳过它们并选择默认区域路由("/Account/{controller}/{action}"
,因此网址与我想要的不同)我该如何继续并解决这个问题?
I have a unusual problem with ASP.NET MVC3 Routing. I created a area named "Account" and inside that a controller "Main" with action "Login". Now I wanted to create a route, that would look something like this: "/Login" (that means no "/Account/Main/Login"), but I keep failing to do that (I have used the AccountAreaRegistration
to register routes, but @Html.ActionLink
always skips them and chooses the default area route ("/Account/{controller}/{action}"
, thus the URL is different from what I want). How can I proceed and solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经解决了我的问题,这实际上很愚蠢。路线的顺序没问题,但问题是由于我在 MapRoute 的默认值列表中使用了area =“Account”默认值而引起的。删除后,一切都像魅力一样。
I have solved my issue, it was actually quite stupid. The order of the routes was OK, but the problem was caused by the fact I did use area = "Account" default value in the list of MapRoute's default values. After I deleted it, everything works like a charm.