Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. User Login

User Login

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netsysadminhelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sean89
    wrote on last edited by
    #1

    I haven't done much ASP.Net so I hope this is a small problem: I have a page where the users can log in to the website. Their role depends on what page they get redirected to, so I am handeling the LoggedIn event of the Login control:

        protected void Login_LoggedIn(object sender, EventArgs e)
        {
            if (User.IsInRole("Admin") == true)
            {
                Server.Transfer("Admin/Default.aspx");
            }
    
            else if (User.IsInRole("SuperAdmin") == true)
            {
                Server.Transfer("SuperAdmin/Default.aspx");
            }
    
            else
            {
                Server.Transfer("User/Default.aspx");
            }
        }
    

    I have no idea if this is the best way to do someting like this... But my problem is that when, let's say the Admin, loggs in they will get the user page(supposed to be admin's) the first time and it says that they have not been authenticated. However, if i hit back and login again it says that they have been authenticated and it goes to the right page. Anyone have any ideas why this is hapening? Thanks in advance ;P -- modified at 13:33 Sunday 23rd April, 2006

    M S 2 Replies Last reply
    0
    • S Sean89

      I haven't done much ASP.Net so I hope this is a small problem: I have a page where the users can log in to the website. Their role depends on what page they get redirected to, so I am handeling the LoggedIn event of the Login control:

          protected void Login_LoggedIn(object sender, EventArgs e)
          {
              if (User.IsInRole("Admin") == true)
              {
                  Server.Transfer("Admin/Default.aspx");
              }
      
              else if (User.IsInRole("SuperAdmin") == true)
              {
                  Server.Transfer("SuperAdmin/Default.aspx");
              }
      
              else
              {
                  Server.Transfer("User/Default.aspx");
              }
          }
      

      I have no idea if this is the best way to do someting like this... But my problem is that when, let's say the Admin, loggs in they will get the user page(supposed to be admin's) the first time and it says that they have not been authenticated. However, if i hit back and login again it says that they have been authenticated and it goes to the right page. Anyone have any ideas why this is hapening? Thanks in advance ;P -- modified at 13:33 Sunday 23rd April, 2006

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      + You should use the Response.Redirect method instead of the Transfer method to redirect the user to the default page. + Another option that you can try in the handler of the LoggedIn event handler is that after you determine the default web page based on the user role, you then simply assign the web page to the DestinationPageUrl property of the Login control, and have the control do the rest.

      S 1 Reply Last reply
      0
      • S Sean89

        I haven't done much ASP.Net so I hope this is a small problem: I have a page where the users can log in to the website. Their role depends on what page they get redirected to, so I am handeling the LoggedIn event of the Login control:

            protected void Login_LoggedIn(object sender, EventArgs e)
            {
                if (User.IsInRole("Admin") == true)
                {
                    Server.Transfer("Admin/Default.aspx");
                }
        
                else if (User.IsInRole("SuperAdmin") == true)
                {
                    Server.Transfer("SuperAdmin/Default.aspx");
                }
        
                else
                {
                    Server.Transfer("User/Default.aspx");
                }
            }
        

        I have no idea if this is the best way to do someting like this... But my problem is that when, let's say the Admin, loggs in they will get the user page(supposed to be admin's) the first time and it says that they have not been authenticated. However, if i hit back and login again it says that they have been authenticated and it goes to the right page. Anyone have any ideas why this is hapening? Thanks in advance ;P -- modified at 13:33 Sunday 23rd April, 2006

        S Offline
        S Offline
        sudharsong
        wrote on last edited by
        #3

        please check with the ispostback is true or false with regards, susa

        1 Reply Last reply
        0
        • M minhpc_bk

          + You should use the Response.Redirect method instead of the Transfer method to redirect the user to the default page. + Another option that you can try in the handler of the LoggedIn event handler is that after you determine the default web page based on the user role, you then simply assign the web page to the DestinationPageUrl property of the Login control, and have the control do the rest.

          S Offline
          S Offline
          Sean89
          wrote on last edited by
          #4

          I dont think you are understanding my question. The user is not getting directed to the right page because they are not being authenticated when they hit login. I put: Response.Write(User.IsAuthenticated.ToString()); on the page that the user kept getting directed to after they logged in and it says false. So for some reason, its not authenticating the user the first time they login. Which is weird because I have made it so that you need to be logged in before you can access the user page and yet it is letting them go there. So its a bit odd :confused: Furthermore, when I switch Server.Transfer to Response.Redirect it keeps sending the user back to the login page!!? Any ideas?

          M 1 Reply Last reply
          0
          • S Sean89

            I dont think you are understanding my question. The user is not getting directed to the right page because they are not being authenticated when they hit login. I put: Response.Write(User.IsAuthenticated.ToString()); on the page that the user kept getting directed to after they logged in and it says false. So for some reason, its not authenticating the user the first time they login. Which is weird because I have made it so that you need to be logged in before you can access the user page and yet it is letting them go there. So its a bit odd :confused: Furthermore, when I switch Server.Transfer to Response.Redirect it keeps sending the user back to the login page!!? Any ideas?

            M Offline
            M Offline
            minhpc_bk
            wrote on last edited by
            #5

            Sean89 wrote:

            I dont think you are understanding my question.

            I'm sorry.

            Sean89 wrote:

            Any ideas?

            IMO, there are a couple of reasons as to why the application sends the user back to the login page: + The username/password is not correct (might not be this case). + The user account is not authorised to view the web page in the Admin or SuperAdmin folder. So could you double check the authorization settings of your application, especially for the Admin/SuperAdmin folder. + The authentication ticket is not added. Have you tried to debug your application and step through your sample code line by line and see what is actually happening?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups