I am using Asp.Net/C#
in my application , I am using Asp.Net
built-in membership framework .The installation of aspnet_regsql
services have been properly installed on my database.The aspnet_users
table however contains basic information about the user , How do I add additional information about a user.Should I modify the table itself or should I use another table and link it with aspnet_users
table.Also the Membership.ValidateUser(username,password)
works well , but I have a requirement where the login is based on the user code.How can I achieve this , is it possible with built-in Membership.
Any suggestions are most welcome.
Thanks

- 6,898
- 11
- 58
- 88
-
Yes, it's all possible. You'll have to detail that "usercode' to get a better answer. – H H Apr 17 '12 at 09:51
-
@HenkHolterman the usercode could be something like 1a , 2a and so on. – Priyank Patel Apr 17 '12 at 09:53
-
And how do you (not) log in with '1a' ? – H H Apr 17 '12 at 09:56
3 Answers
You can use the ProfileProvider
(ref).
More info here: http://msdn.microsoft.com/en-us/library/2y3fs9xs.aspx
And here: How to assign Profile values?
Use an ASP.NET Profile-Provider
instead.
https://web.archive.org/web/20211020111657/https://www.4guysfromrolla.com/articles/101106-1.aspx
You can store any kind of additional information even binary(images).
I've used The SqlProfileProvide
myself in my current application to let the user himself select his startpage.
Therefor i just needed to add this to the web.config
:
<profile defaultProvider="AspNetSqlProfileProvider">
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="RM2ConnectionString" applicationName="/ERP"/>
</providers>
<properties>
<add name="Startpage"/>
</properties>
</profile>
And i could write this property in codebehind:
if(User.Identity.IsAuthenticated)
{
HttpContext.Current.Profile.SetPropertyValue("Startpage", startPage); //startPage is a String
HttpContext.Current.Profile.Save();
}
and read it in the following way:
if(User.Identity.IsAuthenticated)
{
Dim user = Membership.GetUser();
Dim startPage = HttpContext.Current.Profile.GetPropertyValue("Startpage") as String;
}
You can store anything you want, see the link above for further informations.

- 450,073
- 74
- 686
- 939
You could create a custom membership provider by inheriting from System.Web.Security.MembershipProvider
- this way you can implement any additional functionality you need. You can then store the user details in your own table structure etc. You'd then point your web.config at your custom provider to use it.
Useful links:

- 7,541
- 3
- 36
- 45