Solved

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

Posted on 2006-11-17
2
1,373 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
[X]
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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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…
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 antispam), the admini…

710 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