0

I'm creating a new asp.net MVC3 app in which in user table I do not wish to have user name but only user id (long) and email (string). What I would like to understand is normally when I use membership provider with normal db structure, I get the username value in db as the User.Identity.Name.

Could someone please tell me what changes I need to do as I will not have any username in my db to ensure that my email address becomes my User.Identity.Name

Thanks Arnab

Answer: found out... its FormsAuthentication.SetAuthCookie that decides which value goes to user.identity.name

rand0rn
  • 678
  • 2
  • 12
  • 29
Arnab
  • 2,324
  • 6
  • 36
  • 60
  • if you find yourself the answer, please use an answer instead of editing your question. Then, you will be able to mark it as answer, and mark the question as answered. – Steve B Sep 24 '11 at 22:35

2 Answers2

0

The value User.Identity.Name typically comes from the "username" you provide the login form. This is stored by the LogOnModel class within the AccountModels model.

To set your email address as User.Identity.Name, you must provide your email address in the username field of the login form. Then use your membership provider to authenticate the user based on the provided email address.

Eckert
  • 690
  • 4
  • 9
  • but my present logon model class does not have any username but just login id, and I get user.identity.name, it is more likely to be something to do with membership provider as u said, but any idea exactly what happens when u login... – Arnab Sep 22 '11 at 06:44
  • found out... its FormsAuthentication.SetAuthCookie that decides which value goes to user.identity.name – Arnab Sep 24 '11 at 22:32
0

found out... its FormsAuthentication.SetAuthCookie that decides which value goes to user.identity.name

Arnab
  • 2,324
  • 6
  • 36
  • 60