Solved

Asp.net mvc C# aspnet_Users add session for new field

Posted on 2011-02-11
2
1,066 Views
Last Modified: 2013-11-08
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.ValidateUser(model.UserName, model.Password))
                {
                    FormsService.SignIn(model.UserName, model.RememberMe);
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        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(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
            if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");

            return _provider.ValidateUser(userName, password);
        }

0
Comment
Question by:MickeC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Expert Comment

by:Richard Lee
ID: 34941813
I am not sure what your question since you seem to have it worked out. Are you asking how to do it, as in write the code to retrieve the data or you are asking where to put that code?

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
0
 
LVL 10

Accepted Solution

by:
pramodsk40 earned 500 total points
ID: 34955352
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question