This tutorial is intended to be a beginner's introduction to custom session providers. Since the introduction of ASP.NET 2.0, Microsoft has allowed you to tap into its session-state store provider via the
SessionStateStoreProviderBase class. The session-state store inherits from the
abstract SessionStateStoreProviderBase which is made up of the following 12 methods:
You can read more about these methods here.
One of the requirements of my most recent projects was for session data to be stored in Oracle. While this is relatively easy to implement using the built in SQL server provider, it is less obvious how to do this with Oracle. After an extensive web search, I found little information on this subject. Neither Microsoft nor Oracle provided working examples of using Oracle as your session data store. However, Microsoft did have a decent example on how to implement a custom session provider using an Access database. This example was my starting point, and the basic template I used for this article.
Using the Code
In the Web.config:
- Add the Oracle database connection string.
- Add the custom s<place w:st="on"><placename w:st="on">ession-s<placetype w:st="on">tate section.
<add name="COMPANY" connectionString="Data Source=spindev;Persist Security Info=True;
User ID=username;Password=password;Min Pool Size=3;"
<sessionState mode="Custom" customProvider="CustomSessionData"
<add name="CustomSessionData" type="CustomSessionData" />
- Add the custom
OracleSessionProvider to your app_code folder.
Note: At least one session variable must be set for the provider to be initialized.
I have provided you with an example of the basics of implementing a custom session-state provider using an Oracle DB. There are other issues involved in managing session (i.e.,
session_end), but this should get you started.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.