使用jQuery Mobile的ASP.NET Response.Redirect - Url哈希

ric*_*ott 9 c# asp.net jquery jquery-mobile

我有一个标准的表单auth ASP.NET应用程序.我的注册和登录页面与两个jQuery Mobile页面位于同一.aspx文件中.如果我回发我的ASP.NET页面,例如用户无法正确登录...等Url哈希开始一遍又一遍地追加自己.

示例网址:
http:// localhost:56644/Register.aspx?ReturnUrl =%2fDefault.aspx%3fbla%3dtest&bla = test#Register.aspx?ReturnUrl =%2fDefault.aspx%3fbla%3dtest&bla = test

一旦我的用户通过身份验证,我想在没有所有哈希信息的情况下重定向到ReturnUrl,或者在回发期间找到保留网址的方法?

标记:

<div data-role="page" id="register">
    <div data-role="content" data-scroll="true" data-theme="b" class="Content">
        ......  
        <a href='#login'>Login</a               
    </div>
</div>
<div data-role="page" id="login">
    <div data-role="content" data-scroll="true" data-theme="b" class="Content">
        .....                             
        <a href='#register' >Registered Yet?</a>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

Register.aspx上的代码隐藏:

protected void btnLogin_Click(object sender, EventArgs e)
{        
    if (LoggedIn)
    {
        FormsAuthentication.SetAuthCookie("blabla", true); 
        //Note: Request.QueryString["ReturnUrl"] = "/Default.aspx?bla=test";
        Response.Redirect(Request.QueryString["ReturnUrl"]);

    }
}
Run Code Online (Sandbox Code Playgroud)

cto*_*orx 0

protected void btnLogin_Click(object sender, EventArgs e)
{        
    if (LoggedIn)
    {
        FormsAuthentication.SetAuthCookie("blabla", true); 
        //Note: Request.QueryString["ReturnUrl"] = "/Default.aspx?bla=test";

         // This will get only the first instance of ReturnUrl
         var url = Request.Url.PathAndQuery.Substring(
                Request.Url.PathAndQuery.IndexOf("ReturnUrl=") + ("ReturnUrl=").Length);

        Response.Redirect(url);

    }
}
Run Code Online (Sandbox Code Playgroud)