Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference in ASP.NET MVC of RedirectToRoute and RedirectToAction?

What's the difference in ASP.NET MVC of RedirectToRoute and RedirectToAction? It's not clear what the difference is to me.

like image 838
Keltex Avatar asked Feb 22 '10 23:02

Keltex


People also ask

What is RedirectToAction MVC?

RedirectToAction(String, Object) Redirects to the specified action using the action name and route values. RedirectToAction(String, String) Redirects to the specified action using the action name and controller name.

What is the difference between return view and return redirect?

Return View doesn't make a new requests, it just renders the view without changing URLs in the browser's address bar. Return RedirectToAction makes a new request and the URL in the browser's address bar is updated with the generated URL by MVC.

Can we pass model to RedirectToAction in MVC?

When a Button is clicked, the Model object is populated with values and passed to the RedirectToAction method along with the name of the Controller and its Action method in ASP.Net MVC Razor. In this article I will explain with an example, how to redirect to Action method with Model data in ASP.Net MVC Razor.

How do I use RedirectToAction?

The RedirectToAction() MethodThis method is used to redirect to specified action instead of rendering the HTML. In this case, the browser receives the redirect notification and make a new request for the specified action. This acts just like as Response. Redirect() in ASP.NET WebForm.


2 Answers

Redirect to route looks up the route table thats defined in global.asax and redirect to action redirects you to a specified controller/action.

that's about it really

like image 154
griegs Avatar answered Oct 01 '22 20:10

griegs


RedirectToRoute means it redirects to a specific URL which is defined in routing API.(Global.asax)

RedirectToAction will return a http 302 response to the browser and then browser will make GET request to specified action.

like image 29
marvelTracker Avatar answered Oct 01 '22 21:10

marvelTracker