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. get logged in user name

get logged in user name

Scheduled Pinned Locked Moved ASP.NET
securitycsharpasp-netvisual-studio
2 Posts 2 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.
  • P Offline
    P Offline
    Praveen Kandari
    wrote on last edited by
    #1

    I want to display the name of the user that is currently logged on in the system. PS:- Using VS-2013, ASP.NET and I am freshers so please be specific Don't have much idea about authorization, identity or authentication. Thank You

    A 1 Reply Last reply
    0
    • P Praveen Kandari

      I want to display the name of the user that is currently logged on in the system. PS:- Using VS-2013, ASP.NET and I am freshers so please be specific Don't have much idea about authorization, identity or authentication. Thank You

      A Offline
      A Offline
      Afzaal Ahmad Zeeshan
      wrote on last edited by
      #2

      Then the better thing would be to first go and learn ASP.NET's authentication modules, or the framework being used. You might be using Identity; or a WebSecurity-based method of authentication which can be answered by the way you create your application -- as a new project or a new website. If that is the WebSecurity[^]-based application (a website), then you can do that like this,

      var username = WebSecurity.CurrentUserName; // the email field in database

      Or you can get the UserId of the user and query the database to get the Name. Otherwise, if you're using Identity[^], then you would have to query the database anyway; Entity Framework has got you covered! You can get the values from the database as,

      // db is the DbContent variable, and someUserId can be the current user's id.

      db.Users.FirstOrDefault(x => x.Id == someUserId);

      You can then move on and learn other basics about ASP.NET from MSDN, or the best option. Test, try and solve method!

      The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

      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