Solved

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

Posted on 2013-06-26
2
678 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now