저는 ASP.NET MVC 응용 프로그램을 만들고 있습니다. 웬일인지, 나는 내가 라우팅을 이해한다고 생각할 때마다, 내가 이해하지 못하는 것이 튀어 나온다. 현재, 나는 알아낼 수없는 두 가지 경로를 가지고 있습니다. 내 디렉토리 구조 내 global.asax.cs 파일에서MVC 라우팅 오해
- Views
- Internal
- Profile
- Index.cshtml
- Input
- Page1.cshtml
다음, 나는 다음과 같은 매핑을 추가 한 다음과 같습니다 MyController에에서
routes.MapRoute(
"UserProfileInfo",
"{controller}/profile",
new { controller = "Internal", action = "UserProfileInfo" }
);
routes.MapRoute(
"Page1",
"{controller}/input/page1",
new { controller = "Internal", action = "Page1" }
);
을, 나는 다음과 같은 한 :
public ActionResult UserProfileInfo()
{
return View("~/Views/internal/profile/Index.cshtml");
}
public ActionResult Page1()
{
return View("~/Views/internal/input/Page1.cshtml");
}
내 컨트롤러를 하나의 컨트롤러에 저장하고 싶습니다. 나는 내가 모든 것을 올바르게 설정했다고 생각했다. 그러나 나는 404를 계속 얻는다. 내가 뭘 잘못하고 있니?
어떤 URL이 404를 제공합니까? – Simon
http : // localhost : [port]/internal/input/page1 또는 http : // localhost : [port]/profile/info에서 펀치를하면 404가됩니다. http : // localhost를 입력하면 알아 챘습니다. : [port]/internal/UserProfileInfo 내 페이지가 나타납니다. 하지만, 내가 쓰고 싶은 URL이 아닙니다. –
먼저 기존 기본 경로를 제거해야 할 수도 있습니다.이 경로는 먼저 일치 할 수 있습니다. – Simon