CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: Why can't I login to the web even though the User and password are correct ?

  1. #1
    Join Date
    Sep 2007
    Posts
    367

    Why can't I login to the web even though the User and password are correct ?

    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.

    Code:
     
    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 Page</title>
    </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");
         }
    }

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,357

    Re: Why can't I login to the web even though the User and password are correct ?

    Why don't you set some breakpoints and debug the code?

  3. #3
    Join Date
    Sep 2007
    Posts
    367

    Re: Why can't I login to the web even though the User and password are correct ?

    I have debugged that I checked the correct user/password, so I opened "Logon_Redirect.aspx" but it did not load the content of the page, you can see the attached image: http://www.mediafire.com/file/wydeh0...ite2010_09.jpg

    otherwise if I enter the user/pass of the sql server the program loads normally

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,357

    Re: Why can't I login to the web even though the User and password are correct ?

    I can't see the image because you didn't attach the image here. Not going to click on a 3rd party link. You've been told to attach images directly many times before - not sure why you waste people's time by not doing it.

  5. #5
    Join Date
    Sep 2007
    Posts
    367

    Re: Why can't I login to the web even though the User and password are correct ?

    photo here, you see attach file
    Attached Images Attached Images  

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,357

    Re: Why can't I login to the web even though the User and password are correct ?

    Out of curiosity, is there any reason you can't upgrade to .net core?

  7. #7
    Join Date
    Sep 2007
    Posts
    367

    Re: Why can't I login to the web even though the User and password are correct ?

    How do I upgrade a .Net core ?

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,357

    Re: Why can't I login to the web even though the User and password are correct ?

    Quote Originally Posted by dongtrien View Post
    How do I upgrade a .Net core ?
    Upgrade may have been a poor word choice. What I mean't to say is "...why you can't use .net core?"

  9. #9
    Join Date
    Sep 2007
    Posts
    367

    Re: Why can't I login to the web even though the User and password are correct ?

    The problem is not using .net or .net core, each person has an opinion, you don't think so because I feel that it is not necessary to use .net core, can you solve the problem I asked ?

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,357

    Re: Why can't I login to the web even though the User and password are correct ?

    Quote Originally Posted by dongtrien View Post
    The problem is not using .net or .net core, each person has an opinion, you don't think so because I feel that it is not necessary to use .net core, can you solve the problem I asked ?
    Although I began coding 25 years, I only started coding ASP.NET Web apps about 10 years ago with ASP.NET MVC web applications before moving on to web apps in .net core.

    The version of .net you are using predates all of that and is older than anything I have experience with.

    As far as upgrading to later technology, I don't know your situation, but what has allowed me to keep finding work in this business is to stay up on current technologies.

    As an example, I see folks posting questions on how to get VB6 to work on Windows 10 and wonder why they go through the effort of staying with 22 year old technology?

    I don't know if they are hobbyists or professionals but in my area there aren't too many VB6 jobs out there, so if I want to remain working I need to stay up on current technologies. Sure, there is a time investment to learn new things, but it pays off because it generally is easier and simpler to get work done with the newer technology.

  11. #11
    Join Date
    Sep 2007
    Posts
    367

    Re: Why can't I login to the web even though the User and password are correct ?

    It is more convenient to switch to new code, but the new code library is rare, even your site doesn't have a new code library to look for.

  12. #12
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,357

    Re: Why can't I login to the web even though the User and password are correct ?

    Quote Originally Posted by dongtrien View Post
    It is more convenient to switch to new code, but the new code library is rare, even your site doesn't have a new code library to look for.
    I don't understand your response.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)