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. Getting logged on username

Getting logged on username

Scheduled Pinned Locked Moved ASP.NET
securityquestion
5 Posts 4 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.
  • D Offline
    D Offline
    digsy_
    wrote on last edited by
    #1

    My site uses forms authentication (login control etc) to grant users access to the site. Is there a way to programatically get their username once they have logged in ? Thanks

    R K 2 Replies Last reply
    0
    • D digsy_

      My site uses forms authentication (login control etc) to grant users access to the site. Is there a way to programatically get their username once they have logged in ? Thanks

      R Offline
      R Offline
      realJSOP
      wrote on last edited by
      #2

      Yes.

      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

      D 1 Reply Last reply
      0
      • R realJSOP

        Yes.

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        D Offline
        D Offline
        digsy_
        wrote on last edited by
        #3

        And what is the way ?

        J 1 Reply Last reply
        0
        • D digsy_

          And what is the way ?

          J Offline
          J Offline
          Jon Sagara
          wrote on last edited by
          #4

          It has been a long time since I last worked with this stuff, but you can try the Page.User.Identity.Name property, or see if you can get what you need by using the Membership.GetUser()[^] method.

          Jon Sagara Once again, the conservative sandwich-heavy portfolio pays off for the hungry investor! *slurp* Oh, I'm ruined! -- Dr. Zoidberg .NET Blog | Personal Blog | Articles

          1 Reply Last reply
          0
          • D digsy_

            My site uses forms authentication (login control etc) to grant users access to the site. Is there a way to programatically get their username once they have logged in ? Thanks

            K Offline
            K Offline
            kaushal_prabhakar
            wrote on last edited by
            #5

            Yes, You can do it. There are various method available but the simplest way is to use 'cookies':), like this, ' on "Login.aspx.vb" page Dim uname As String = Login1.UserName Dim pwd As String = Login1.Password e.Authenticated= FormsAuthentication.Authenticate(uname,pwd) If FormsAuthentication.Authenticate(uname, pwd) Then FormsAuthentication.RedirectFromLoginPage(uname, True) Response.Cookies("CokieLogin").Value = uname Else Login1.FailureText = "Either User Name or Password is wrong." End If 'On "Default.aspx.vb" page Dim UserName As String = UCase(Request.Cookies("CokieLogin").Value) 'here we expire the cookies Response.Cookies("CokieLogin").Expires = System.DateTime.Now()

            prabhakar

            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