locked
Membership provider issue. RRS feed

  • Question

  • User350923160 posted

    Hello everyone,

    I have a question about creating a login control in an asp.net webform.

    I created a new project >> web forms (not empty) and then it generated several directories for me including account. 

    I went to the main web.config file and edited the DefaultConnection attribute connection string to a remote SQL server. I ran the Registration.aspx web form under the Account directory and created a new user name and I was successful. I logged in to the remote database and confirmed the creation of several tables. The user name was created in one of the new tables. I then created a new login page outside the content folder under the root of the project and set it to be the startup page for the project. I added a login control to this page and changed its DestinationPageUrl property to a page under the content folder. When I run the application and try to log in using the new account with the login control I get this error message:

    Default Membership Provider must be specified

     I have no Idea how to create this.

    Any ideas?

    Best,

    Ali

    Tuesday, August 9, 2016 9:29 PM

Answers

All replies

  • User-2057865890 posted

    Hi Ali,

    Here , I have shared a link of Microsoft Documentation of How to specify Default Provider.

    In that they had mentioned an example of that.

    You need to add <Membership> in Web.Config File like below.

    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add 
              name="SqlProvider" 
              type="System.Web.Security.SqlMembershipProvider" 
              connectionStringName="MySqlConnection"
              applicationName="MyApplication"
              enablePasswordRetrieval="false"
              enablePasswordReset="true"
              requiresQuestionAndAnswer="true"
              requiresUniqueEmail="true"
              passwordFormat="Hashed" />
          </providers>
        </membership>
    

    Configuring an ASP.NET Application to Use Membership
    https://msdn.microsoft.com/en-us/library/6e9y4s5t.aspx

    Regards

    Chris

    Wednesday, August 10, 2016 6:43 AM
  • User350923160 posted

    I edited the web.config file and added the suggested code and when I run it I get the following error: 

    Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'. 

    If it helps:

    here is the default code for the membership attribute in my main web.config file.

    <membership>
          <providers>
            <!--
    	      ASP.NET Membership is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
            -->
            <clear />
          </providers>
        </membership>

    Maybe I am using the wrong template. Is this possible? What I did is I created a new project from Visual studio Pro 2013 >> new >> project >> ASP.NET Web Application >> Web Forms.

    I ran the Register.aspx page and created an account.  After that I created a Separate Login.aspx page (there is one under Account directory). Then I added an ASP Login control. The default Login page works when I type in the user credentials but when I use the login control under the Login page under the root, it doesn't recognize any membership provider because according to the web.config file it is disabled.

    Any ideas?

    Thanks

    Wednesday, August 10, 2016 2:42 PM
  • User-2057865890 posted

    Hi Aazizasp,

    When you create a new project, at that time it will use a new Asp.net Identity.
    You can add your membership providers after that.
    For more detailed information regarding this, you can visit link below.
    Getting started with Asp.net Identity
    http://www.asp.net/aspnet/overview/authentication-and-identity 
    Introducing ASP.NET Identity – A membership system for ASP.NET applications
    https://blogs.msdn.microsoft.com/webdev/2013/06/27/introducing-asp-net-identity-a-membership-system-for-asp-net-applications/ 
    Then if we talk about the error, then for that I find the link has the same issue like yours.
    Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'
    http://stackoverflow.com/questions/2165908/could-not-find-stored-procedure-dbo-aspnet-checkschemaversion

    Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 11, 2016 10:48 AM