컨트롤러 작업의 매개 변수를 정수로 제한하기 위해 경로를 가져 오는 데 문제가 있습니다.ASP.NET MVC 경로가 제약 조건과 함께 작동하지 않습니다.
[RequiresRole(RoleToCheckFor = "Administrator"), AcceptVerbs(HttpVerbs.Get)]
public ActionResult Edit(int id)
{
...
}
및 Global.asax.cs에 다음과 같은 경로 : 다음과 같이
나는 AA 컨트롤러 액션이
routes.MapRoute(
"UserEdit",
"user/edit/{id}",
new {controller = "user", action = "edit"},
new {id = @"\d+"}
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
routes.MapRoute("Error",
"{*url}",
new { controller = "Error", action = "notfound" });
내가 때문에 기대하고있어 그 난 http://domain.com/user/edit/ABCD 내가 shouldn을 입력하면 ' 다음과 같은 일반적인 오류가 발생합니다 :
매개 변수 사전에 null이 포함되어 있습니다 매개 변수 방법이 아닌 nullable 형식 '선택 System.Int32'의 '아이디' 'System.Web.Mvc.ActionResult 편집 (INT32)'
이 (내가 생각하는)에 대한 항목도 http://www.asp.net/%28S%28pdfrohu0ajmwt445fanvj2r3%29%29/learn/mvc/tutorial-24-cs.aspx
말했다 무엇 정확하게그러나 여전히 "... null 항목 ..."오류가 표시됩니다.
이유가 무엇입니까? 경로 설정에 문제가 있습니까?
감사