5
실패 :Asp.net MVC 3 라우팅 영역 나는이 경로를
WebSite/Global.asax.cs
에 내 웹 사이트 경로 :
namespace WebSite
{
public class MvcApplication : HttpApplication
{
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
...
routes.MapRoute(
"Default",
"Authenticated/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "WebSite.Controllers" }
);
...
}
void Application_Start()
{
...
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
...
}
}
}
WebSite/Areas/Admin/AdminAreaRegistration.cs
에 내 관리 지역 경로 :
namespace WebSite.Areas.Admin
{
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"qwerty/Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new[] { "WebSite.Areas.Admin.Controllers" }
);
}
}
}
내 URL을 :
WebSite: http://www.mywebsite.com/Authenticated/Controller/Action...
Admin: http://www.mywebsite.com/qwerty/Admin/Controller/Action...
내 문제 :
웹 사이트 URL을 사용하면 "qwerty/Admin"을 사용하지 않고 Admin Area에서 Controllers/Actions를 호출 할 수 있으며 올바르지 않습니다. 이 문제를 어떻게 해결할 수 있습니까?
감사합니다.
컨트롤러 경로를 정의하지 않았기 때문에 관리 경로가 컨트롤러 동작에 맞지 않을 수 있습니다. "Controller ="Home "문을 의미합니다. –
@ Andrey.Gubal 웹 사이트와 관리 영역에 같은 이름의 컨트롤러가 두 개있는 경우 동일한 문제가 발생합니다. 경로에 네임 스페이스를 넣었지만 아무 것도 해결하지 못했습니다. – Cesar