0
新的一页
我有我的网页上的按钮下面的标记代码:的Response.Redirect只刷新页面,并不重定向用户
<asp:Button ID="LoginButton" runat="server"
CssClass="ButtonColor"
Text="Log In"
Width="75px" height="20px"
OnClientClick="setCookie();"
OnClick="LoginButton_Click"
/>
这里是LoginButton_Click:
Protected Sub LoginButton_Click(sender As Object, e As EventArgs)
'Check if username/password is valid
' Dim gn = New BA_Shared_Object_Library.Data.SQLServer("GetNext 2.0 (DEV)", BA_Shared_Object_Library.Data.SQLServer.ConnectionConfigurationTypeEnum.DatabaseName)
Dim CredentialsValid = Membership.ValidateUser(UserName.Text, Password.Text)
If (CredentialsValid) Then
'Add User Session stuff
Session.Add("MFUserName", UserName.Text)
Session.Add("MFPW", Password.Text)
Response.Redirect("MFACheck.aspx", False)
Else
End If
End Sub
当这执行,我遍历代码并点击Response.Redirect行。但是,不是重定向,而是刷新页面。我究竟做错了什么?
我已经试过
我已经试过Response.Redirect("~/MFACheck.aspx", False)
我缺少什么?
谢谢
尝试'Response.Redirect(“〜/ MFACheck.aspx”,true);'。请参阅[Response.Redirect MSDN参考](https://msdn.microsoft.com/en-us/library/a8wa7sdt(v = vs.110).aspx)。 – sammarcow
您可能会被重定向回登录页面,因为您尚未实际登录用户。在重定向之前,使用'FormsAuthentication.RedirectFromLoginPage'方法(它将创建auth cookie)或使用'FormsAuthentication.SetAuthCookie'手动添加cookie。 – user1429080