2009年7月31日 星期五

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/eu...f-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.AccessMembershipProv ider,
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







connectionString="~/App_Data/ASPNetDB.mdb"
providerName="System.Data.OleDb"/>










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"/>



cacheRolesInCookie="true" cookieName=".ASPXROLES" cookieTimeout="30"
cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="All">


type="AccessProviders.AccessRoleProvider,
ASP.NET.AccessProviders"
connectionStringName="AccessFileName"
applicationName="SampleSite"/>





type="AccessProviders.AccessProfileProvider,
ASP.NET.AccessProviders"
connectionStringName="AccessFileName"
applicationName="SampleSite"
description="Stores and retrieves profile data from
an ASP.NET_Access_Providers database."/>



serializeAs="String"/>

serializeAs="String"/>

serializeAs="Xml"/>



cookieName=".ASPXANONYMOUS" cookieTimeout="100000" cookiePath="/"
cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="None" domain=""/>


defaultProvider="AccessPersonalizationProvider">



type="AccessProviders.AccessPersonalizationProvide r,
ASP.NET.AccessProviders"
connectionStringName="AccessFileName"
applicationName="SampleSite"/>










You can also put the absolute path in the connection strings



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

沒有留言:

張貼留言

推到 Twitter!
推到 Plurk!
推到 Facebook!