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 107557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:46:22+00:00 2026-05-11T01:46:22+00:00

For the life of me, I cannot get the SqlProfileProvider to work in an

  • 0

For the life of me, I cannot get the SqlProfileProvider to work in an MVC project that I’m working on.

The first interesting thing that I realized is that Visual Studio does not automatically generate the ProfileCommon proxy class for you. That’s not a big deal since it’s simpy a matter of extending the ProfileBase class. After creating a ProfileCommon class, I wrote the following Action method for creating the user profile.

[AcceptVerbs('POST')] public ActionResult CreateProfile(string company, string phone, string fax, string city, string state, string zip) {     MembershipUser user = Membership.GetUser();     ProfileCommon profile = ProfileCommon.Create(user.UserName, user.IsApproved) as ProfileCommon;      profile.Company = company;     profile.Phone = phone;     profile.Fax = fax;     profile.City = city;     profile.State = state;     profile.Zip = zip;     profile.Save();      return RedirectToAction('Index', 'Account');  }

The problem that I’m having is that the call to ProfileCommon.Create() cannot cast to type ProfileCommon, so I’m not able to get back my profile object, which obviously causes the next line to fail since profile is null.

Following is a snippet of my web.config:

<profile defaultProvider='AspNetSqlProfileProvider' automaticSaveEnabled='false' enabled='true'>     <providers>         <clear/>         <add name='AspNetSqlProfileProvider' type='System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' connectionStringName='ApplicationServices' applicationName='/' />     </providers>     <properties>         <add name='FirstName' type='string' />         <add name='LastName' type='string' />         <add name='Company' type='string' />         <add name='Phone' type='string' />         <add name='Fax' type='string' />         <add name='City' type='string' />         <add name='State' type='string' />         <add name='Zip' type='string' />         <add name='Email' type='string' >     </properties> </profile>

The MembershipProvider is working without a hitch, so I know that the connection string is good.

Just in case it's helpful, here is my ProfileCommon class:

public class ProfileCommon : ProfileBase     {         public virtual string Company         {             get             {                 return ((string)(this.GetPropertyValue('Company')));             }             set             {                 this.SetPropertyValue('Company', value);             }         }          public virtual string Phone         {             get             {                 return ((string)(this.GetPropertyValue('Phone')));             }             set             {                 this.SetPropertyValue('Phone', value);             }         }          public virtual string Fax         {             get             {                 return ((string)(this.GetPropertyValue('Fax')));             }             set             {                 this.SetPropertyValue('Fax', value);             }         }          public virtual string City         {             get             {                 return ((string)(this.GetPropertyValue('City')));             }             set             {                 this.SetPropertyValue('City', value);             }         }          public virtual string State         {             get             {                 return ((string)(this.GetPropertyValue('State')));             }             set             {                 this.SetPropertyValue('State', value);             }         }          public virtual string Zip         {             get             {                 return ((string)(this.GetPropertyValue('Zip')));             }             set             {                 this.SetPropertyValue('Zip', value);             }         }          public virtual ProfileCommon GetProfile(string username)         {             return ((ProfileCommon)(ProfileBase.Create(username)));         }     }

Any thoughts on what I might be doing wrong? Have any of the rest of you successfully integrated a ProfileProvider with your ASP.NET MVC projects?

Thank you in advance...

  • 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. 2026-05-11T01:46:23+00:00Added an answer on May 11, 2026 at 1:46 am

    Here’s what you need to do:

    1) In Web.config’s section, add ‘inherits’ attribute in addition to your other attribute settings:

    <profile inherits='MySite.Models.ProfileCommon' defaultProvider='.... 

    2) Remove entire <properties> section from Web.config, since you have already defined them in your custom ProfileCommon class and also instructed to inherit from your custom class in previous step

    3) Change the code of your ProfileCommon.GetProfile() method to

    public virtual ProfileCommon GetProfile(string username)         {                  return Create(username) as ProfileCommon;       } 

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot get Bindable LINQ to work with VB.NET for the life of me.
I just for the life of me cannot get an AJAX call to work
For some reason I cannot get this to work for the life of me,
I cannot seem to get the Maven Glassfish plugin working for the life of
For the life of me I cannot seem to get relationships to work on
I cannot for the life of me get this. Example of fails, the last
I cannot work this out to save my life! So, I have a Codeigniter
I have a crash in my app that I cannot debug for the life
For the life of me I cannot get my Superfish menu to stop hiding
For the life of me I cannot get the bash script to execute the

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.