0

In LogIn method I have:

FormsAuthentication.SetAuthCookie(model.User, false);

and to get name of this user we use

 User.Identity.Name

Is possible to get for example type account from databese?

I mean, during when user is Loging, type account is send (to cookie?). And use this type in view using something like User.Identity.Name without using controller. Is possible to do something like that?

user1031034
  • 836
  • 1
  • 14
  • 38
  • Your question is not very clear. What do you mean by type account? You can get to the user identity in the view without including it in the controller or viewbag, but I'm not sure that's what you want. – tbddeveloper Dec 14 '11 at 22:09
  • type account... I mean e.g. two type of acount 1. admin 2. supervisor – user1031034 Dec 15 '11 at 00:20

1 Answers1

1

If I'm understanding your question right, I think your best bet would be using an ASP.NET Profile Provider. With the Profile Provider, you can do something like:

HttpContext.Current.Profile.AccountType

You'll need to do a few things to make it work in MVC. See here for more info:

Implementing Profile Provider in ASP.NET MVC

Hopefully this helps, and I'm interpreting your question correctly.

Community
  • 1
  • 1
Garrett Vlieger
  • 9,354
  • 4
  • 32
  • 44