Solved

Custom MembershipProvider - web.config error: Cannot create an abstract class.

Posted on 2006-11-17
2
1,351 Views
Last Modified: 2012-05-05
App_Code:
HamotMembershipProvider.vb -

Imports Microsoft.VisualBasic
Imports System.Data

Public MustInherit Class HamotMembershipProvider
    Inherits System.Web.Security.MembershipProvider
    Private hfunctions As New hamot_functions
    Private connStr As String = hfunctions.sConnectionString
    Private comm As New Data.OleDb.OleDbCommand

    Private _requiresQuestionAndAnswer As Boolean
    Private _minRequiredPasswordLength As Integer

....snip....

    Public Overrides Function ValidateUser(ByVal username As String, ByVal password As String) As Boolean
        Dim sSql As String = "SELECT userid FROM dbo.sys_users WHERE user_name='" & username & "' AND password='" & password & "'"
        Dim drUserCredentials As Data.SqlClient.SqlDataReader = hfunctions.get_datareader(connStr, sSql)
        Dim bReturn As Boolean = False

        If Not IsNothing(drUserCredentials) Then
            If drUserCredentials.HasRows Then
                bReturn = True
            End If
        End If
        drUserCredentials.Close()
        drUserCredentials = Nothing

        ValidateUser = bReturn
    End Function

...snip..
End Class

================================
web.config-

      <system.web>
            <authentication mode="Forms">
                  <forms loginUrl="default.aspx" name=".ASPXFORMSAUTH" />
            </authentication>
            <membership defaultProvider="HamotMembershipProvider">
                  <providers>
                        <add name="HamotMembershipProvider" type="System.Web.Security.MembershipProvider" />
                  </providers>
            </membership>

...snip..
================================
Error Output:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Cannot create an abstract class.

Source Error:


Line 21:             <membership defaultProvider="HamotMembershipProvider">
Line 22:                   <providers>
Line 23:                         <add name="HamotMembershipProvider" type="System.Web.Security.MembershipProvider" />
Line 24:                   </providers>
Line 25:             </membership>
0
Comment
Question by:EchoBinary
2 Comments
 
LVL 12

Accepted Solution

by:
AGBrown earned 500 total points
ID: 17972396
If you implement your own membership provider, it _must_ be an instantiable class, i.e., not abstract. So you need to get rid of the MustInherit in your class definition above.

Is that possible, and does that help?

Andy
0
 
LVL 3

Expert Comment

by:rundkaas
ID: 17974418
Your problem as far as I can see it, is that the type is wrong!
You are using the following: type="System.Web.Security.MembershipProvider"
but this should realy be type="myNameSpace.HamotMembershipProvider", where myNameSpace is the namespace where HamotMembershipProvider resides.

What you are doing here is to load a new instace of the abstract System.Web.Security.MembershipProvider ,an calling the reference: "HamotMembershipProvider"
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

13 Experts available now in Live!

Get 1:1 Help Now