Asp.net mvc ReturnUrl复制参数-MVC 4

Asp.net mvc ReturnUrl复制参数-MVC 4,asp.net-mvc,duplicates,query-string,Asp.net Mvc,Duplicates,Query String,我对retunUrl有问题,因为它复制了我的查询字符串参数 我的url类似于: “www.mysite.com/Order/?id=1&item=123” 然后,将我重定向到登录页面,url如下所示: “www.mysite.com/login/RedirectUrl=/Order?id=1&item=123&id=1&item=123” 用户登录后,操作重定向到: “www.mysite.com/Order/?id=1&item=123&id=1&item=123” 在我的页面中,当我使用Re

我对retunUrl有问题,因为它复制了我的查询字符串参数

我的url类似于:

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

然后,将我重定向到登录页面,url如下所示:

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

用户登录后,操作重定向到:

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

在我的页面中,当我使用Request.QueryString[“id”]时,我得到了一个错误,因为QueryString“id”是重复的

我的登录操作代码如下所示:

[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();
}

如何解决这个问题?

我认为问题在于顺序控制器或返回URL分配逻辑。它可能会添加url+查询字符串。如果是,您可以尝试类似于Request.Url.GetLeftPart(UriPartial.Path)+queryString的方法!谢谢你的回复。DidWork=(…Request.Url.GetLeftPart(UriPartial.Path)返回“www.mysite.com”,Request.QueryString.ToString()返回“RedirectUrl=/Order?id=1&item=123&id=1&item=123”,因为此时QueryString就是“RedirectUrl”尝试。再次感谢,但这不是我的情况…我需要查询字符串,但我不需要重复的查询字符串。我知道如何获取第一个查询字符串,即使这是重复的,但我不想为我的所有页面执行此操作…我有20+…我需要在登录操作中解决此问题。