Using RedirectToAction

The RedicrectToAction simply generates a HTTP 302 code witch tells the browser to get the next page.
It is important to remember that when this is used inside a view then we should return RedicrectToAction. This will render the View to the client (and make it redirect) and will stop any further execution (if the RedirectToAction for instance is inside a if statement)

public ActionResult Upload(UploadOrderModel uploadorder)
{
	if (uploadorder.IsInvalid)
	{
		//somthing fishy is going on ...
		return RedirectToAction("Index", "Home");
	}
	//do important things here
	return View(orderInfo);
}

system.web.mvc.controller.redirecttoaction at msdn

Tags: , , ,

Leave a Reply