重定向不会更改url c#

重定向不会更改url c#,c#,asp.net,jquery,jquery-mobile,C#,Asp.net,Jquery,Jquery Mobile,我正在使用jQuery和jQueryMobile框架构建asp.net网站。成功登录后,我可以看到下一页的内容,但URL保持不变,即/login.aspx 当我按F5键时,只有URL更改 Login.aspx <div data-role="content"> <form id="frmLogin" method="post" runat="server" action="Login.aspx"> <div data-role="fieldc

我正在使用jQuery和jQueryMobile框架构建asp.net网站。成功登录后,我可以看到下一页的内容,但URL保持不变,即
/login.aspx

当我按F5键时,只有URL更改

Login.aspx

<div data-role="content">
    <form id="frmLogin" method="post" runat="server" action="Login.aspx">
        <div data-role="fieldcontain">
            <input type="text" name="txtUserName" id="txtUserName" placeholder="User Name" value="" runat="server" /><br />
            <input type="password" name="txtUserPass" id="txtUserPass" placeholder="Password" value="" runat="server" />
            <br />          
            <button id="cmdLogin" type="button">Login</button>
        </div>
    </form>
    <div id="divDialog"></div>
</div>
登录代码隐藏

Login.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack)
    {       
        routeToDefaultPage();
    }   
}
private void routeToDefaultPage()
{
    Response.Redirect("Piechart.aspx");
}
这里有什么问题?

当我在成功登录后检查元素时(内容为
Piecharts.aspx
,但URL为
login.aspx
)。我在标题部分看到以下内容

<base href="http://localhost:49712/Login.aspx">

单击时,是否确定已将标志ispostback指定为true。这条线上的断点可以帮助您吗?

试试以下方法:

Response.Redirect("Piechart.aspx");
Response.End();

ajax调用后的jquery重定向呢

尝试在ajax调用成功后添加此选项<代码>标题('Location:Piechart.aspx')

$('#cmdLogin').click(function () {
        $.ajax({
        url: 'ajaxExecute.aspx?Fn=VUSR',
        type: 'POST',
        context: document.body,
        data: 'User=' + $('#txtUserName').val() + '&Pass=' + $('#txtUserPass').val(),
        cache: false,
        success: function (response) {
            // redirects page after login successful
            header( 'Location: Piechart.aspx' );            

            alert(f);
            if (response == '1') {                    
                f.submit();
            }
            else {
                /*
                Print Error
                */
            }
        }
    });
});
这对我有用

$.mobile.changePage( "/Piecharts.aspx", {
  transition: "pop"
});

尝试另一个浏览器,看看它是否会更改它是一个移动网站…我在Chrome和Android浏览器中尝试过..它在移动设备的opera mini web浏览器上运行良好。是的,当您单击“登录”按钮时,断点会命中。。。甚至调用了函数routeToDefaultPage()。这就是为什么我能够看到
Piecharts.aspx
page抱歉,我不明白问题所在,您被重定向到了正确的页面,但URL没有更改。您是否尝试使用Response.redirect(“/Piecharts.aspx”)重定向到绝对路径;您也可以在重定向到clear cache Response.clear()之前进行尝试?
$.mobile.changePage( "/Piecharts.aspx", {
  transition: "pop"
});