MickeC
asked on
Asp.net mvc C# aspnet_Users add session for new field
Hallo,
I added a field in table 'aspnet_Users' in the default database cald 'fk_company_id', when the user login i want to grab the 'fk_company_id' and store it in a session to access it im my webb aplication. Im using microsoft default login. Im new att this any sugetions?
Controller:
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (MembershipService.Validat eUser(mode l.UserName , model.Password))
{
FormsService.SignIn(model. UserName, model.RememberMe);
if (!String.IsNullOrEmpty(ret urnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Home", "Home");
}
}
else
{
ModelState.AddModelError(" ", "The user name or password provided is incorrect.");
}
}
Moddel:
public bool ValidateUser(string userName, string password)
{
if (String.IsNullOrEmpty(user Name)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(pass word)) throw new ArgumentException("Value cannot be null or empty.", "password");
return _provider.ValidateUser(use rName, password);
}
I added a field in table 'aspnet_Users' in the default database cald 'fk_company_id', when the user login i want to grab the 'fk_company_id' and store it in a session to access it im my webb aplication. Im using microsoft default login. Im new att this any sugetions?
Controller:
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (MembershipService.Validat
{
FormsService.SignIn(model.
if (!String.IsNullOrEmpty(ret
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Home", "Home");
}
}
else
{
ModelState.AddModelError("
}
}
Moddel:
public bool ValidateUser(string userName, string password)
{
if (String.IsNullOrEmpty(user
if (String.IsNullOrEmpty(pass
return _provider.ValidateUser(use
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1. Check if user successfully logged on
http://msdn.microsoft.com/en-us/library/system.web.httprequest.isauthenticated.aspx
http://www.velocityreviews.com/forums/t371466-check-if-logged-in.html
2. Retrieve the data
3. Store in session. Session["Something"] = 1;
DaTribe