Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should i use RedirectToAction?

Is there any difference between:

public ActionResult logOff()
{
    FormsAuth.SignOut();
    return RedirectToAction("index", "Home");
}

And:

public ActionResult logOff()
{
    FormsAuth.SignOut();
    return index();
}
like image 977
Rodrigo Manguinho Avatar asked Jan 17 '23 08:01

Rodrigo Manguinho


1 Answers

Yes.

With RedirectToAction() your users will be redirected to Index page (that's what they'll see on the browser address bar). Simply returning the result of your index() method instead will fill the current page (LogOff?) with the content of the other page.

In this case maybe there is no difference but if your action performs some logic then you may have problems when users simply refresh the page.

like image 191
Adriano Repetti Avatar answered Jan 18 '23 21:01

Adriano Repetti