내보내기(0) 인쇄
모두 확장
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오.
번역
원본

Controller.HandleUnknownAction 메서드

요청이 이 컨트롤러와 일치하지만 지정된 작업 이름을 포함하는 메서드를 컨트롤러에서 찾을 수 없을 때 호출됩니다.

네임스페이스:  System.Web.Mvc
어셈블리:  System.Web.Mvc(System.Web.Mvc.dll)

protected virtual void HandleUnknownAction(
	string actionName
)

매개 변수

actionName
형식: System.String
시도된 작업의 이름입니다.

The result object that is prepared by this method is written to the response by the ASP.NET MVC framework when the object is executed.

A Visual Studio project with source code is available to accompany this topic: Download.

The following example shows how to render views that do not have a matching ActionResult method. For example, if you have a Details.aspx view but no corresponding method exists that returns an ActionResult instance, the following example displays the Details view when a request to for the Details action is made on the controller. If there is no matching view, the error page displays a message. This example shows one way to use the HandleUnknownAction method. Action methods are not required to return an ActionResult object.

protected override void HandleUnknownAction(string actionName) {
    try {
        this.View(actionName).ExecuteResult(this.ControllerContext);
    }
    catch (InvalidOperationException ieox ) {
        ViewData["error"] = "Unknown Action: \"" + 
            Server.HtmlEncode(actionName) + "\"";
        ViewData["exMessage"] = ieox.Message;
        this.View("Error").ExecuteResult(this.ControllerContext);
    }
}  

커뮤니티 추가 항목

추가
표시:
© 2015 Microsoft