Tuesday, September 3, 2013

ReturnUrl Duplicating Parameters - MVC 4

I'm having problem with retunUrl what is duplicating my QueryString parameters.


My url is like:


"www.mysite.com/Order/?id=1&item=123"


then, redirect me to login page and the url look like:


"www.mysite.com/login/RedirectUrl=/Order?id=1&item=123&id=1&item=123"


After the user login, the action redirect to:


"www.mysite.com/Order/?id=1&item=123& id=1&item=123 "


In my page when i use Request.QueryString["id"] i got an error, because the querystring "ID" is duplicated.


My login Action code look like this:



[HttpPost]
[AllowAnonymous]
public ActionResult Index(LoginModel model, string ReturnUrl)
{
if(VerifyLogin(model))
{
if(ReturnUrl != null)
return Redirect(ReturnUrl);//redirect to url with duplicated parameters
else
return Redirect("/Home");
}
else
{
ModelState.AddModelError("", "Invalid Username or Password");
}

return View();
}


How i can solve this problem?



No comments:

Post a Comment