I am setting up my first MVC site, and I just implemented a security and presentation controller.
However, I do not understand how I can save registered user data through my controllers.
For example, a user logs in with an email / password. Then I can check if the letters and passwords match, and I do the following:
FormsAuthentication.SetAuthCookie(userLogin.UserName, false);
return View("../Home/Index");
Now let's say, for example, I want data to be displayed in the Index view, which only the user can see.
I have a table setup, but it is based on user_id.
Is it possible to save user_id at login or is there something already available to access their email (to the user)? (Then I could search for an identifier by email, if necessary)
My MVC is configured to use forms authentication:
<authentication mode="Forms">
<forms loginUrl="~/Security/Login" timeout="2880" />
</authentication>
and I decorated the controllers with an [Authorize] annotation.
source
share