enb081
enb081

Reputation: 4051

Redirect to ReturnUrl in MVC 2

I have this URL

http://localhost:49460/Account/Login?ReturnUrl=%2fusers%2fuser%2f5199

How do I redirect to the view Users/User/5199?

Upvotes: 1

Views: 435

Answers (1)

Curtis
Curtis

Reputation: 103348

First pass the ReturnUrl as a string parameter on your controller, and redirect to that string value if its not null, like so:

public ActionResult Login(string ReturnUrl){
   //logic here
   if (ReturnUrl != null){
      return Redirect(ReturnUrl);
   }
   //Default return in case ReturnUrl is null goes here
}

Upvotes: 4

Related Questions