Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Function after success of Jquery/AJAX action 9 28
Add a Condition in ASP Repeater 6 34
ASP Repeater control - onl;y show if flag is true 7 15
SSIS Start 2 20
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

860 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