?
Solved

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

Posted on 2013-06-26
2
Medium Priority
?
781 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

864 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