Click here to Skip to main content
6,628,952 members and growing! (17,898 online)
Email Password   helpLost your password?
Web Development » ASP.NET » General     Intermediate

ASP.NET session state store provider for MySql

By Harry Kimpel

A brief description on how to set-up MySql as session state store for ASP.NET
C# 2.0.NET 2.0, WinXP, Vista, ASP.NET, SQL Server, WebForms, MySQL, VS2005, Architect, DBA, Dev
Posted:20 Sep 2007
Updated:18 Oct 2007
Views:10,097
Bookmarked:11 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
3 votes for this article.
Popularity: 1.11 Rating: 2.33 out of 5
1 vote, 33.3%
1

2

3

4
2 votes, 66.7%
5

Introduction

This article describes how to set-up an ASP.NET project in order to use MySql as its session state store provider.

Using the code

Looking on the web I was not able to find a suitable solution that uses MySql as its session state store. It may certainly be possible that there is already a better solution available (if so, please do not hesitate to contact me). However, I was able to find a sample session state store provider using MS Access. That's it! Port it to MySql ... and that's what I did.
But, let's do it step by step. The list below gives you an idea on what I did in order to get it to work:
  1. Downloaded the sample session state store provider for MS Access from MSDN.
  2. Downloaded the .NET Connector (using version 5.0.7) from MySql.
  3. Ported the sample code provided by Microsoft for use with MySql (the zipped source code can be found here).
  4. Adjusted the Web.config accordingly:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<connectionStrings>

<add name="MySqlSessionServices" connectionString="Database=<name of database>; Data Source=<host>; User Id=<login>; Password=<password>"/>

</connectionStrings>

<system.web>

<sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="MySqlSessionProvider">

<providers>

<add name="MySqlSessionProvider" type="Samples.AspNet.Session.MySqlSessionStateStore" connectionStringName="MySqlSessionServices" writeExceptionsToEventLog="false"/>
</providers>

</sessionState>

</system.web>

</configuration>

You can check it out at www.kimpel.com ... it works like a charm .

Please do not hesitate to contact me if you have any questions and/or comments.

History

2007-09-20: initial version

2007-10-17: updated link to sources

<script type="text/javascript" src="http://i.ixnp.com/shot_main_js/v2.26.1/"></script><script type="text/javascript" src="http://shots.snap.com//snap_shots.js?ro=1&ap=1&tc=0&tp=1&hdd=1500&si=0&key=38278c431bc885d2e8b29b587e4c5d90&th=silver&sb=1&link_icon=on&shots_trigger=both&size=small&lang=en-us&campaign=addon_ff_1.3.0&plugin=1"></script>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Harry Kimpel


Member

Occupation: Web Developer
Location: Germany Germany

Other popular ASP.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralGreat! [modified] Pinmemberdevjunkie1:19 11 Jan '09  
GeneralBug... [modified] PinmemberJohannes750:44 1 May '08  
QuestionWill this work for ASP.NET 1.1? Pinmemberajdiaz7:03 3 Jan '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 18 Oct 2007
Editor:
Copyright 2007 by Harry Kimpel
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project