Solved

Membership.Getuser() works in asp.net 2.0 but not in asp.net 4.5

Posted on 2013-06-26
2
682 Views
Last Modified: 2013-06-26
aspx file

    string strUserName = User.Identity.Name;
    MembershipUser currentUser = Membership.GetUser(strUserName);

Default Membership Provider could not be found.
The exception that is thrown when a configuration system error has occurred.

The web.config file is exactly what I used when the app was created in asp.net 4.5.
I know that the Membership object uses the SQL membership database.

What should I change?

Thanks,

web.config:
=========
<connectionStrings>
    <remove name="MemberShipSQLConnectionString"/>
    <add name="MemberShipSQLConnectionString"
         connectionString="Initial Catalog=aspnetstockpro;
         Data Source=tcp:SQLB37.webcontrolcenter.com;
         User ID=Dovberman;Password=1088Delb!;connection timeout =30"
         providerName="System.Data.SqlClient"/>
    <add name="conStockSelect" connectionString="Initial Catalog=stockprosql; &#xD;&#xA; Data Source=tcp:SQLB37.webcontrolcenter.com; &#xD;&#xA; User ID=Dovberman;Password=1088Delb!;connection timeout =30"
         providerName="System.Data.SqlClient"/>
    <add name="StockSelectSQLConnectionString" connectionString="Initial Catalog=stockprosql; Data Source=tcp:SQLB37.webcontrolcenter.com; User ID=Dovberman; Password=1088Delb!; connection timeout =30"
         providerName="System.Data.SqlClient"/>
    <add name="conStockSelectLocal" connectionString="Initial Catalog=stockprosql;&#xD;&#xA; Data Source=PC-ADMIN  connection timeout =30"
         providerName="System.Data.SqlClient"/>
  </connectionStrings>

   <membership defaultProvider="DefaultMembershipProvider">
     
      <providers>
       
        <add name="SQLProvider" connectionStringName="MemberShipSQLConnectionString"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             applicationName="StockPro"
             requiresUniqueEmail="true"
             passwordFormat="Hashed"
             maxInvalidPasswordAttempts="5"
             passwordAttemptWindow="10"
             minRequiredNonalphanumericCharacters="0"
             minRequiredPasswordLength="8"
             type="System.Web.Security.SqlMembershipProvider"/>
      </providers>
 
    </membership>

    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
        <add name="CustomizedRoleProvider"
        type="System.Web.Security.SqlRoleProvider"
        connectionStringName="MemberShipSQLConnectionString"
        applicationName="StockPro"/>
      </providers>
    </roleManager>

   <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
0
Comment
Question by:Dovberman
  • 2
2 Comments
 

Accepted Solution

by:
Dovberman earned 0 total points
ID: 39278363
This fixed it:
Changed this:

 <membership defaultProvider="DefaultMembershipProvider">
     
      <providers>
       
        <add name="SQLProvider" connectionStringName="MemberShipSQLConnectionString"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             applicationName="StockPro"
             requiresUniqueEmail="true"
             passwordFormat="Hashed"
             maxInvalidPasswordAttempts="5"
             passwordAttemptWindow="10"
             minRequiredNonalphanumericCharacters="0"
             minRequiredPasswordLength="8"
             type="System.Web.Security.SqlMembershipProvider"/>
      </providers>
 
    </membership>



To this:

   <membership defaultProvider="SQLProvider">

      <providers>
       
        <add name="SQLProvider"
             connectionStringName="MemberShipSQLConnectionString"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             applicationName="StockPro"
             requiresUniqueEmail="true"
             passwordFormat="Hashed"
             maxInvalidPasswordAttempts="5"
             passwordAttemptWindow="10"
             minRequiredNonalphanumericCharacters="0"
             minRequiredPasswordLength="8"
             type="System.Web.Security.SqlMembershipProvider"/>
      </providers>
 
    </membership>
0
 

Author Closing Comment

by:Dovberman
ID: 39278366
Sometimes one word makes a difference.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question