return View() :
It commend to generate HTML to display for the required view and render/send it to the browser
Example :
public ActionResult Index()
{
UserDetailModel obj = new UserDetailModel();
obj.CountryDetail = new List<Country>()
{
…….
};return View(obj);
}
In this above code the view isย (it never call any controller) which is referring the Action Method.
This below also work like above
[HttpPost]
public ActionResult Index(string Name)
{
return MyIndex();
}
return Redirect()
It commend to redirect to specified URL instead of rendering HTML (ie., it redirect to new URL)
Example
[HttpPost]
public ActionResult Index(string Name)
{
return Redirect(“Home/TIndex”);
}
return RedirectToAction()
It commend to redirect to specified action instead of rendering HTML
Example
[HttpPost]
public ActionResult Index(string Name)
{
return RedirectToAction(“TIndex”);
}
Note :
1)ย Return View doesn’t make a new requests, it renders the view without changing URLs in the browser’s address bar. (ie., simple like Server.Transfer() )
2)ย Return RedirectToAction makes a new requests and URL in the browser’s address bar is changed (ie., simple like Response.Redirect() )
RedirectToAction(“CustomerDetail”, “Customers”, new { CustomerID = 1001 })
In this above,it will generate the URL for you based on your route table.CustomerID will pass to the customerDetail action method under theย CustomerFolder
3)ย Redirect also work same as RedirectToAction , but you have to mention full URL to redirect
Hi Thiyagu,
In my site, i have a problem.
I want use RedirectToAction() but keep before url, can i do it?
Sorry for my english.