从 ReturnUrl 返回 MVC 5 中的 QueryString

Returning QueryString in MVC 5 from ReturnUrl

如果用户要去登陆页面,然后被重定向到登录页面,url 将如下所示

https://OurDomain.com/HA5/Secure/Login?ReturnUrl=%2FHA5%2FSecure%2FLanding%2F

我已经尝试了各种方法来获取查询字符串

Request.QueryString("ReturnUrl") returns 没有

System.Web.HttpContext.Current.Request.Url.PathAndQuery 不包含查询字符串。

我错过了什么?

谢谢

这是一个很长的路要走,但我能找到的唯一方法是通过 jQuery

传递值
 var vPath = window.location.href;
jQuery.ajax({
            url: '@Url.Action("ReturnURL", "Login")',
    type: 'POST',
    data: { FullURL: vPath },
    success: function (response) {
        if (response.indexOf('Invalid') >= 0) {
            //They got here from an old link
            window.location.href = '/secure/redirect/';
        }
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        ModalError(textStatus + " - " + errorThrown);
    }



})

控制器(保存为会话的值)

 <HttpPost()>
    Function ReturnURL(FullURL As String) As ActionResult
        Try
            If FullURL.Contains("ReturnUrl") Then
                Dim vID As Integer = FullURL.IndexOf("=")
                Dim vSub As String = FullURL.Substring(vID + 1)
                Session("ReturnUrl") = vSub.Replace("%2F", "/")
            End If

            Return Json("Success")
        Catch ex As Exception
            EmailError(ex, 53, PageName)
            Return Json("Invalid")
        End Try
    End Function