Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8311095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:41:55+00:00 2026-06-08T19:41:55+00:00

Bear in mind, I have researched this and have found several articles, however, they

  • 0

Bear in mind, I have researched this and have found several articles, however, they are mostly old (like from 2008) so I am wanting more recent information pertaining to the latest version(s) of ASP.NET MVC.

I am using the Membership built-in thing to provide user registration, login and roles.

I want to use the profile functions, too.

I don’t know how to create a profile and I can’t find any articles on how to do this in MVC 3. I found one using MVC 2, maybe it’s the same, but I want to use the latest available methods.

Can someone show me a step by step solution to creating a profile?

I am considering using my own membership classes + forms authentication. That way, creating profiles is as simple as assigning a foreign key…

What’s the experts’ opinion?

Please provide your answer in VB and not C# (I don’t know why everyone writes me stuff in C#).

Thanks.

Edit: Here is my Register function:

'
' POST: /Account/Register

<HttpPost()> _
Public Function Register(ByVal model As RegisterModel) As ActionResult
    If ModelState.IsValid Then
        ' Attempt to register the user
        Dim createStatus As MembershipCreateStatus
        Membership.CreateUser(model.UserName, model.Password, model.Email, Nothing, Nothing, True, Nothing, createStatus)

        If createStatus = MembershipCreateStatus.Success Then
            FormsAuthentication.SetAuthCookie(model.UserName, False)
            Return RedirectToAction("Index", "Home")
        Else
            ModelState.AddModelError("", ErrorCodeToString(createStatus))
        End If
    End If

    ' If we got this far, something failed, redisplay form
    Return View(model)
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:41:56+00:00Added an answer on June 8, 2026 at 7:41 pm

    Personally, I would recommend against using the SQL Profile Provider (which is what you are using). Nothing has changed with profiles since MVC2 (or, for that matter, since it was introduced in webforms with .NET 2.0).

    The reason is this: Profile data is stored as XML in the database, which makes it very difficult to use profile data outside of your app (meaning in a pure SQL query).

    You’re probably much better off creating profile fields in your database directly. This way you know which table / column the data is coming from, and can create views if you need to. Otherwise, you would have to parse a table column’s XML to extract the profile data (which is what the ProfileCommon does in .NET).

    Reply to comments

    First of all, I was wrong about the property name. It is ProviderUserKey, not ProviderKey. However unless you want to store profile properties for anonymous users, you could just as easily use MembershipUser.UserName as your FK value, since it will also be unique.

    [HttpPost]
    public ActionResult Register(RegisterModel model)
    {
        MembershipCreateStatus createStatus;
        var membershipUser = Membership.CreateUser(model.UserName, model.Password, 
            model.Email, null, null, true, null, out createStatus);
    
        if (createStatus == MembershipCreateStatus.Success)
        {
            var providerKeyObject = membershipUser.ProviderUserKey;
            var providerKeyGuid = (Guid)membershipUser.ProviderUserKey;
            // Use providerKeyGuid as a foreign key when inserting into a profile
            // table. You don't need a real db-level FK relationship between
            // your profile table and the aspnet_Users table. You can lookup this
            // Guid at any time by just getting the ProviderUserKey property of the
            // MembershipUser, casting it to a Guid, and executing your SQL.
    
            // Example using EF / DbContext
            using (var db = new MyDbContext())
            {
                var profile = new MyProfileEntity
                {
                    UserId = providerKeyGuid, // assumes this property is a Guid
                    FirstName = model.FirstName,
                    LastName = model.LastName,
                };
                db.Set<MyProfileEntity>().Add(profile);
                db.SaveChanges();
            }
    
            // you could get the profile back out like this
            using (var db = new MyDbContext())
            {
                var profile = db.Set<MyProfileEntity>().SingleOrDefault(p => 
                    p.UserId == (Guid)membershipUser.ProviderUserKey);
            }
            FormsAuthentication.SetAuthCookie(membershipUser.UserName, false);
            return RedirectToAction("Index", "Home");
        }
        return View(model);
    }
    

    Here is an example using the UserName instead of the ProviderUserKey. I would recommend this approach if you are not storing profile info for anonymous users:

    [HttpPost]
    public ActionResult Register(RegisterModel model)
    {
        MembershipCreateStatus createStatus;
        var membershipUser = Membership.CreateUser(model.UserName, model.Password, 
            model.Email, null, null, true, null, out createStatus);
    
        if (createStatus == MembershipCreateStatus.Success)
        {
            // Example using EF / DbContext
            using (var db = new MyDbContext())
            {
                var profile = new MyProfileEntity
                {
                    // assumes this property is a string, not a Guid
                    UserId = membershipUser.UserName,
                    FirstName = model.FirstName,
                    LastName = model.LastName,
                };
                db.Set<MyProfileEntity>().Add(profile);
                db.SaveChanges();
            }
    
            // you could get the profile back out like this, but only after the 
            // auth cookie is written (it populates User.Identity.Name)
            using (var db = new MyDbContext())
            {
                var profile = db.Set<MyProfileEntity>().SingleOrDefault(p => 
                    p.UserId == User.Identity.Name);
            }
            FormsAuthentication.SetAuthCookie(membershipUser.UserName, false);
            return RedirectToAction("Index", "Home");
        }
        return View(model);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: Bear in mind that while this code works on
This might sound like a strange question, but bear with me... I have a
Please bear in mind that I'm totally new to Rails when answering this.My question
Bear with me if this is unclear; I have trouble fully wrapping my head
I have a decorator chain that looks like this when initially created: IType calculator
I have a controller posts: www.mydomain.com/posts/123-hello Please bear in mind that the 123 is
So, I have some JSON I'm deserialising. Bear in mind I don't have control
The following is a code snippet of my application. Bear in mind that I
Bear with me, as I'm quite new to using regular expressions. I have regexp
Bear with me, as this is my first Android app. :) Essentially, I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.