ActionResult

ActionResult is an object used in ASP.Net MVC.  ActionResult returns or passes things like ViewResult to views and many more.

If you simply want to return view then

If you want to redirect user to other url

If you want to redirect user to another action

If you want to add some parameters to the action

If you just need to return https status code result, you can also use (include System.Web.Mvc).  Check https://msdn.microsoft.com/en-us/library/system.web.mvc.httpstatuscoderesult(v=vs.118).aspx for more detail.

There are more in HttpStatusCode, and you can return more precise and appropriate status code to the user;

  • Member – Status Code
  • OK – 200
  • Created – 201
  • MovedPermanently – 301
  • Found – 302
  • SeeOther – 303
  • BadRequest – 400
  • Unauthorized – 401
  • Forbidden – 403
  • NotFound – 404
  • MethodNotAllowed – 405
  • InternalServerError – 500

I haven’t use this myself, but you can return nothing too

You can also simply return contents like text

I ll introduce more about later.

 

Leave a Reply