Wednesday, November 23, 2011

Use MS Access for Asp.net Personalization

Asp.net provides default option for personalization, that is using Sql server.

What if sql server is not installed on a server ? Here you can use the Asp.net personalization using MS Access.

Just follow the simple steps :

Download the Sample Access Providers provided by Microsoft.
This is a .vsi file and you could run it to get installed. But rather then doing that, you simply rename the extension from vsi to zip and unzip the file.
you can see access.csproject and ASPNetDB.mdb files.
Now open the access.csproject project and build it, it should create a dll named "SampleAccessProviders.dll"
Open your website where you need to implement MS Access personalization.
Now add reference of 'SampleAccessProviders.dll' from the location you built it.
Copy ASPNetDB.mdb file under App_Data folder.
Now only some configuration settings are left!
Just open your website web.config
you need to the following settings:
First of all the connectionstring to the access database:
<connectionStrings>
<add name="AccessDbFile" connectionString="~/App_Data/ASPNetDB.mdb"
providerName="System.Data.OleDb"/>
connectionStrings>
Also change the authentication mode  Forms  this:
<authentication mode="Forms">
<forms loginUrl="mylogin.aspx" defaultUrl="Login.aspx"/>
authentication> 
After that you can simply copy in the providers that you need.

<membership defaultProvider="AccessMembershipProvider">
<providers>         <clear/>      
<add name="AccessMembershipProvider"              
type="Samples.AccessProviders.AccessMembershipProvider, SampleAccessProviders"
connectionStringName="AccessDbFile"        
enablePasswordRetrieval="false"              enablePasswordReset="false" 
requiresUniqueEmail="false"          
requiresQuestionAndAnswer="false"              minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"              
applicationName="SampleSite"              hashAlgorithmType="SHA1"      
passwordFormat="Hashed"/>     providers> membership>

1 comment:

  1. Asp.net provides default option for personalization, that is using Sql server.Thanks for your valuable information. dot net training and placement in chennai

    ReplyDelete