Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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 …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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