How to use MS Access DB for ASPNET Application Services (membership, profile, etc)

Discussion in 'ASP .Net' started by Anonieko, Jul 5, 2006.

  1. Anonieko

    Anonieko Guest

    A lot of times, web hostings for ASPNET 2.0 will offer only MS Access
    DB for database for basic plan, a question often asked is how can I use
    the membership services, role, web parts services, etc for this MS
    Access db. Well, microsoft offers a download sample. Instructions
    are below.



    HOW TO USE MS ACCESS DB FOR ASPNET APPLICATION SERVICES ( membership,
    profile, roles, etc providers)



    1. Download the Sample Access Provider from microsoft.

    http://msdn.microsoft.com/vstudio/eula.aspx?id=96713a8e-b8d4-4d6e-bb8f-027e6c8e15d8


    This will install a VSI which you can open in Visual Studio 2005.
    It contains a sample web.config as well as sample ASPnetDb.mdb


    NOTE: web.config has an incorrect provider type. For example:

    type="Samples.AccessProviders.AccessMembershipProvider,
    SampleAccessProviders"



    "SampleAccessProviders" should have been "ASP.NET Access Providers"
    because
    that is the name of the DLL created by this class library.


    You can use either of this:

    1. Change the name of DLL. (by right-clicking on project, in
    Applications tab, change the type to 'SampleAccessProviders'.
    or


    2. Change every occurrence of "SampleAccessProviders" in web.config
    with "ASP.NET Access Providers"



    In any case, you should be able to get rid the "unable to load Type"
    runtime error.




    You should create the DLL by compiling the class library project.


    2. Create a new web site. Copy ASPnetDb.mdb in the 'App_Data'
    directory.
    Incorporate the sample web.config file in the class library into the

    web.config file in your new website.



    3. Select your website in visual studio, Launch ASPNET Configuration
    Wizard.
    You should be able now to add security.




    For example, I changed the namespace of the Sample access providers
    project to 'AccessProviders' and also changed the DLL to
    'ASP.NET.AccessProviders.dll'



    Here is my working sample web.config




    <configuration>
    <connectionStrings>
    <add name="AccessFileName"
    connectionString="~/App_Data/ASPNetDB.mdb"
    providerName="System.Data.OleDb"/>
    </connectionStrings>
    <system.web>
    <authentication mode="Forms">
    <forms loginUrl="mylogin.aspx" defaultUrl="Login.aspx"/>
    </authentication>

    <membership defaultProvider="AccessMembershipProvider">
    <providers>
    <clear/>
    <add name="AccessMembershipProvider"
    type="AccessProviders.AccessMembershipProvider,
    ASP.NET.AccessProviders"
    connectionStringName="AccessFileName"
    enablePasswordRetrieval="false"
    enablePasswordReset="false"
    requiresUniqueEmail="false"
    requiresQuestionAndAnswer="false"
    minRequiredPasswordLength="1"
    minRequiredNonalphanumericCharacters="0"
    applicationName="SampleSite"
    hashAlgorithmType="SHA1"
    passwordFormat="Hashed"/>
    </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="AccessRoleProvider"
    cacheRolesInCookie="true" cookieName=".ASPXROLES" cookieTimeout="30"
    cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true"
    cookieProtection="All">
    <providers>
    <add name="AccessRoleProvider"
    type="AccessProviders.AccessRoleProvider,
    ASP.NET.AccessProviders"
    connectionStringName="AccessFileName"
    applicationName="SampleSite"/>
    </providers>
    </roleManager>
    <profile enabled="true" defaultProvider="AccessProfileProvider">
    <providers>
    <add name="AccessProfileProvider"
    type="AccessProviders.AccessProfileProvider,
    ASP.NET.AccessProviders"
    connectionStringName="AccessFileName"
    applicationName="SampleSite"
    description="Stores and retrieves profile data from
    an ASP.NET_Access_Providers database."/>
    </providers>
    <properties>
    <add name="FriendlyName" type="string" allowAnonymous="true"
    serializeAs="String"/>
    <add name="Height" type="int" allowAnonymous="true"
    serializeAs="String"/>
    <add name="Weight" type="int" allowAnonymous="true"
    serializeAs="Xml"/>
    </properties>
    </profile>
    <anonymousIdentification enabled="true"
    cookieName=".ASPXANONYMOUS" cookieTimeout="100000" cookiePath="/"
    cookieRequireSSL="false" cookieSlidingExpiration="true"
    cookieProtection="None" domain=""/>
    <webParts>
    <personalization
    defaultProvider="AccessPersonalizationProvider">
    <providers>
    <add name="AccessPersonalizationProvider"

    type="AccessProviders.AccessPersonalizationProvider,
    ASP.NET.AccessProviders"
    connectionStringName="AccessFileName"
    applicationName="SampleSite"/>
    </providers>
    </personalization>
    </webParts>

    <!--
    <trust level="Medium"/>
    -->

    <compilation debug="true"/>
    </system.web>
    </configuration>






    You can also put the absolute path in the connection strings


    <connectionStrings>
    AccessFileName"
    connectionString="D:\Clients\C240\msite.com\database/ASPNetDB.mdb"
    providerName="System.Data.OleDb"/>
    </connectionStrings>







    --------------------------------------------------------------------------------
    Last Updated 7/5/2006 7:19:21 AM by 'Editor'
    Home | Edit page | List pages | Recent pages | RSS Search for:
     
    Anonieko, Jul 5, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    0
    Views:
    394
    VB Programmer
    Jan 18, 2006
  2. Brad
    Replies:
    1
    Views:
    1,144
    Roedy Green
    Jul 19, 2005
  3. Andy B
    Replies:
    0
    Views:
    528
    Andy B
    May 3, 2008
  4. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    418
    Fredrik Lundh
    Aug 13, 2008
  5. va
    Replies:
    0
    Views:
    168
Loading...

Share This Page