Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

RedirectToAction or Redirect?

$
0
0

I'm wondering what is the most effective way of returning from an editpost method to the Edit view?

So after updating a post I can either do this

return RedirectToAction("Edit", new { ID = id });

or this:

string url = $"/Post/Edit/{id}";

return Redirect(url);

The edit action method(that both these return statements sends an id to) is just the standard fetch whatever post that belongs to id, populate it in a viewmodel and return it to view.

I'm wondering if using Redirect() is faster or has some benefits over the first one? Maybe the only difference is that in the redirectto action i also create a new variable, and that they work exactly the same in my case?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>