Solved

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

Posted on 2006-11-17
2
1,352 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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 …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

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

14 Experts available now in Live!

Get 1:1 Help Now