잊지 않겠습니다.

Action Result

.NET Framework 2009. 1. 7. 13:00

Controller에서 View에게 명령을 넘겨주는 Action에 대한 결과값

 

Method

  • View : return ViewResult instance
    • View를 호출하는 경우에는 Controller가 동작하지 않는다. View()가 되는 순간에 View가 호출이 되고, 단지 보여지는 방법을 공유할때 사용된다.(url이 변경되지 않는다.)
  • Redirect : redirects to the specified URL. Returns a RedirectResult result
    • Controller가 실행되고, url이 변경되게 된다.
  • RedirectToAction : Accepts an action and redirects to another controller action. Returns aRedirectToRouteResult instance,
  • RedirectToRoute : Redirects to a ULR that is determined by the routing API. this method lets you specify a named route. Returns a RedirectToRouteResult instance.
  • Json : Return JsonResult instance.
  • Content : send text context to the response. Returns a ContentResult instance.

 

ActionResult Type

  • ViewResult : Renders the specified view to the response.
  • EmptyResult : Does nothing. return null instance.
  • RedirectResult : Performs an HTTP redirect to the specified URL.
    • - controller가 있는 경우 controller method가 실행되고, 그 결과가 리턴되게 된다.
  • RedirectToRouteResult : Given some routing values, uses the routing API to determine tue URL and then redirects to that URL
  • JsonResult : Serializes the specified ViewData object to JSON format
  • ContentResult : Writes the specified text context to the response.

 

Posted by Y2K
,