0

I am using ASP.net membership, but I want to store additional information for client while registration instead of default columns as membership provider does, so how can I customize the dbo.aspnet_Users table and change the code so that it doesn't affect the other functionality and works fine?

Could somebody suggest me on it how can I achieve this?

4
  • 3
    One word: DON'T ! I would never modify such a table that's provided by another system. If you need additional info - store that into an additional table that references the aspnet_Users table via a common, shared PK (acting as a FK in your additional table)
    – marc_s
    Mar 31, 2012 at 8:05
  • Create a new table, set that table's PK to be the same datatype as the PK of the aspnet_Users table, create a foreign key relationship between those two tables, and then fill in the data as needed. You'll need to be able to get all that data when the registration completes - never done that myself, but the "4 Guys from Rolla" website (mentioned by Tim in his response) has tons of good articles on the ASP.NET membership system and how to customize and extend it
    – marc_s
    Mar 31, 2012 at 8:13
  • Ok, i see, thanks for your help, if any queries arise i revert back to you, thanks Mar 31, 2012 at 8:51
  • There i see they are using two wizards, can't use a single and merge info in 1 wizard only... ? Mar 31, 2012 at 9:35

1 Answer 1

1

Use an ASP.NET Profile-Provider.

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 currect application to let the user chose his startpage self. Therefor i only 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.

9
  • There i see they are using two wizards, can't use a single and merge info in 1 wizard only... ? Mar 31, 2012 at 9:35
  • @NoviceToDotNet: You don't need any wizard at all. Edited my answer. Mar 31, 2012 at 11:26
  • i did the same as you mentioned but says"This property cannot be set for anonymous users." Apr 2, 2012 at 11:15
  • i am writing the above code at the RegisterUser_CreatedUser event Apr 2, 2012 at 11:17
  • @NoviceToDotNet: I've edited my answer to show how to check if user is authenticated, maybe that helps. Apr 2, 2012 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.