In ASP.NET MVC incoming browser request mapped to a controller’s action method and that action method returns type of ActionResult in response to the browsers request. I was playing bit with ASP.NET MVC3 to check out new features of ASP.NET MVC 3 and I have found three great new ActionResult Type. Below is details explanation of each one.
- HttpNotFound: This return type returns a error 404 on client. This action result type can be very useful when we have resources that are not found and so we can notify the client with 404 error.
- RedirectResult:This returns a temporary redirect code 302 or permanent redirect code 302 depending upon a Boolean flag. This kind of redirection is very important for Search Engine optimization. I have already discussed this feature with asp.net 4.0 here.
- HttpStatusCodeResult: Returns a user specified code so developer have choice to return specific error code.
Here are code example of Action ResultType how we can use that in code.
public ActionResult SpecificResult()Hope you liked it.. Stat tuned for more..Happy Programming
return new HttpStatusCodeResult(404);
public ActionResult NotFound()
public ActionResult PermanentRedidrect()
return new RedirectResult("http://jalpesh.blogspot.com");