【发布时间】:2014-09-11 01:36:39
【问题描述】:
我正在为区域编写路线,但我在同一个 URL 上遇到了问题。这是我的网络结构:
Project Authentication:
AccountController
|__SignIn
Project Account:
AccountController
|__ChangePassword
我写路线:
AccountAreaRegistration 中的第一条路由:
context.MapRoute(
"Account_Default",
"Account/{action}/{id}",
new
{
controller = "Account",
id = UrlParameter.Optional
},
new[] { "MyProject.Account.Controllers" });
AuthenticationAreaRegistration 中的第二条路由:
context.MapRoute(
"Authentication_Account",
"Account/SignIn",
new
{
controller = "Account",
action = "SignIn",
id = UrlParameter.Optional
},
new[] { "MyProject.Authentication.Controllers" });
第一个路由的优先级高于第二个路由,因为 AccountAreaRegistration 在 AuthenticationAreaRegistration 之前调用。
当我打开 URL:~/Account/SignIn -> 我收到错误资源未找到,因为此 URL 与第一个路由匹配。如何解决我的问题。谢谢。
【问题讨论】:
标签: c# .net asp.net-mvc routing