Returnurl=%2f проблема в ASP.NET проверка подлинности форм
When I Loged into the web and clicked on Login, it was navigating to the LogIn page but it adds 'ReturnUrl=%2f' to the URL. For example, authentication.aspx?ReturnUrl=%2fAXERP-UAT%2fsubsystem%2fmain_menu.aspx.After Login, it should point to this page subsystem/main_menu.aspx. Can anyone help me? Thanks a lot.
Что я уже пробовал:
----------------------------------web.config
<appSettings> <add key="ConnectionString" value="AX-UAT;Integrated Security=false;Initial Catalog=SBG_AX_2020;User ID=sbax;Password=sbax;Connection TimeOut=99999" /> </appSettings> <authentication mode="Forms"> <forms name="AXERP-UAT" loginUrl="authentication.aspx" protection="All" path="/" timeout="1500" /> </authentication> <authorization> <deny users="*" /> </authorization>
----------------------------КОДИРОВАНИЕ С#
protected void authenticate(object sender, EventArgs e) { if (txtUsername.Text == null | txtUsername.Text == string.Empty) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Error? Please enter email address');", true); return; } if (txtPassword.Text == null | txtPassword.Text == string.Empty) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Error? Please enter password');", true); return; } SqlConnection con_Check_UserData = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); SqlCommand cmd_Check_UserData = new SqlCommand(); try { cmd_Check_UserData.CommandText = "select * from VIEW_LOGIN where username = '" + txtUsername.Text + "' and password = '" + txtPassword.Text + "'"; cmd_Check_UserData.Connection = con_Check_UserData; con_Check_UserData.Open(); System.Data.SqlClient.SqlDataReader rd_Check_UserData = cmd_Check_UserData.ExecuteReader(System.Data.CommandBehavior.CloseConnection); if (rd_Check_UserData.HasRows) { while (rd_Check_UserData.Read()) { rd_Check_UserData.Read(); ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Login Successful');", true); Response.Redirect("subsystem/main_menu.aspx"); FormsAuthentication.RedirectFromLoginPage(txtUsername.Text.ToLower(), false); } } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Invalid Username/ Password');", true); return; } } catch (Exception ex) { con_Check_UserData.Close(); Lbl_Message.Text = ex.Message; //Response.Redirect("main_menu.aspx"); return; } finally { con_Check_UserData.Close(); } con_Check_UserData.Dispose(); cmd_Check_UserData.Dispose(); con_Check_UserData = null; cmd_Check_UserData = null; }