A
Anonieko
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>
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>