I am writing a small example of Login webSite, there are two types of accounts and passwords, one is an account and password is stored in the Web.config file and the other two accounts and passwords are saved in SQL Server database, My problem is that in form 1, when logging in it opens Logon_Redirect.aspx file but cannot access, the following is my code
I am debugging and running to the code where this opens the Logon_Redirect.aspx file but nothing, but when I log in with another account and password (the user password of SQL Server) log in well.
In file Web.config
- <appSettings>
- ...
- <add key="SmtpServer" value="localhost"/>
- <add key="EmailWebmaster" value="admin"/>
- <add key="Password" value="123"/>
- ...
- appSettings>
In file Logon_Redirect.aspx
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head runat="server">
- <title>Untitled Pagetitle>
- head>
- <body>
- <form id="form1" runat="server">
- <div>
- div>
- form>
- body>
- html>
In file Logon_Redirect.aspx.cs
- public partial class Logon_Redirect : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- // kiem tra va Redirect toi trang can thiet
- if (Page.User.IsInRole(Globals.Settings.AppRoles.KhachHang))
- Response.Redirect(Globals.ApplicationPath);
- else if (Page.User.IsInRole(Globals.Settings.AppRoles.Admin))
- Response.Redirect(Globals.ApplicationPath + "WebMaster/Contacts/Contact.aspx");
- }
- }
In file Logon.aspx.cs
- protected void btLogon_Click(object sender, EventArgs e)
- {
- //I can't Login User/Pass in file Web.config, check User: admin and Pass: 123
- if (Membership.ValidateUser(txtEmail.Text, txtPassword.Text))
- {
- if (Request.QueryString["ReturnUrl"] != null)
- {
- FormsAuthentication.RedirectFromLoginPage(txtEmail.Text, false);
- }
- else
- {
- FormsAuthentication.SetAuthCookie(txtEmail.Text, false);
- Session["username"] = txtEmail.Text.Trim();
- Response.Redirect(Globals.ApplicationPath + "Logon_Redirect.aspx");
- //I am debugging and running to the code here and opens the Logon_Redirect.aspx file but nothing
- }
- }
- else //Login SQL Server very good
- {
- // check User/pass other on SQL Server
- if (webapp4U.BOL.User.CheckUserName(txtEmail.Text) && txtPassword.Text == ConfigurationManager.AppSettings["Password"].ToString())
- {
- FormsAuthentication.SetAuthCookie(txtEmail.Text, false);
- Session["username"] = txtEmail.Text.Trim();
- Response.Redirect(Globals.ApplicationPath + "Logon_Redirect.aspx");
- }
- else
- lblMsg.Text = ResourceManager.GetString("Logon_False");
- }
- }

Laxmidhar SahooRank #383 · 6.6K reputationPosted Jan 10, 2020, 10:55 PM EST
Jignesh KumarRank #91 · 22.9K reputationPosted Jan 11, 2020, 4:21 PM EST
Dong Lam TrienRank #1,538 · 1K reputationPosted Jan 15, 2020, 3:31 AM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Jan 15, 2020, 6:20 AM EST
Dong Lam TrienRank #1,538 · 1K reputationPosted Jan 17, 2020, 7:39 AM EST
Dong Lam TrienRank #1,538 · 1K reputationPosted Jan 30, 2020, 10:40 PM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Jan 31, 2020, 6:35 PM EST
Dong Lam TrienRank #1,538 · 1K reputationPosted Feb 18, 2020, 9:33 PM EST