views:

20

answers:

1

I have ASP.NET MVC site with authentication dialog (login/password) that is accessible on every page. When user provides login/password post-back is initiated to special controller, not the same as the one generated the page with dialog. I do some authentication stuff and wish to return user's browser to the same page request came from. I do the following (simplified):

protected ActionResult Authorize(string login, string password) 
{
  ... 
  return Redirect(Request.UrlReferrer.AbsoluteUri);
}

what is the best practice to perform such action?

Thank you in advance!

A: 

In the default Membership of ASP.NET they simply use a returnUrl parameter in the query string. I find that this gets the job done quite well. It also allows me to bounce them to a different url if that is what the requirement is.

There is nothing wrong with the way you are doing it now, I just prefer the flexibility of the query string parameter.

kayos
I can do the same, but I'll have to add hidden field "Return Url" to form posted back. I am not sure it's a best practice. I've heard also UrlReferrer field can be not populated for some reason.
Andrew Florko