Click here to Skip to main content
Click here to Skip to main content

ASP.NET session state store provider for MySQL

, 18 Oct 2007
Rate this:
Please Sign up or sign in to vote.
A brief description on how to set-up MySQL as session state store for ASP.NET.

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 of 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:
  5. <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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Harry Kimpel
Web Developer
Germany Germany
No Biography provided

Comments and Discussions

 
Questionplz brack main code Pinmembersaqibali211918-Aug-11 8:02 
<?xml version="1.0" encoding="utf-8"?>
<LicenceManager xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://visionontech.com/vbp/LicenceConfiguration">
   <ApplicationName>ovE1c/0l6IoKP/KF6bpqv22zqoYuT3Wv</ApplicationName>
   <LicenseType>7Ax330npgHE=</LicenseType>
   <VersionType>bbUl/DISjDzJkqERNmGqY8eWlTKz+Er3qSWdcEGFDUdsWo9DJrviULY/entknwWw2Z67rm0RnqeB3ENiAa1blfEkGPtfeELVxVG44JG4J5w=</VersionType>
   <CompanyName>KWZwGJLdl+pI240K/PURWg==</CompanyName>
   <SerialNumber>7515b594-6afb-4f0f-bf4c-13351339191c</SerialNumber>
   <MachineID>I50NMYu1RZix+7AuMOhIDyhyFkiepjdK1Sy93luDdi4nCxRLW+Yy259FgXAvKvX9</MachineID>
   <Signature>9XvKvAXgF952yY+WLRxCn4idDul39yS1KdjpeikFyhyDIhOMuA7+xiZR1uYMN05I</Signature>
   <City>Q6H8NNOnO80=</City>
   <CreatedBy>TZdhgIlUIBo2BIm8yvL3ww==</CreatedBy>
   <LicenseCreationDate>1xtf7PZmvZQ5e+ohObsHFHokaELQyvIq</LicenseCreationDate>
</LicenceManager>
 
my laptop Licence is
i m other copy use of plz help me every one thanks
GeneralGreat! [modified] Pinmemberdevjunkie11-Jan-09 0:19 
GeneralBug... [modified] PinmemberJohannes7530-Apr-08 23:44 
QuestionWill this work for ASP.NET 1.1? Pinmemberajdiaz3-Jan-08 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 18 Oct 2007
Article Copyright 2007 by Harry Kimpel
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid