Storing Data from [dbo].[AspNetUsers] RRS feed

  • Question

  • User-812572070 posted

    Hi, I am making an app where I have a table called users and rentals. Rentals have userId as a foreign key. Now I want not to let users fill in, but it should automatically take current logged in user. How do I do that? 

    Can anyone help?

    Thursday, November 15, 2018 5:05 PM

All replies

  • User475983607 posted

    If you are using Identity, the user Id (and username) are available within every request after a successful login.  Use this line to get the user's Id.

    var userId = User.Identity.GetUserId()

    Security basics are covered in the ASP.NET tutorials found by clicking the "Learn" link above.


    Thursday, November 15, 2018 5:54 PM