473,385 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to write a HttpModule to replace built-in Session?

Hi There!

Is it possible to use HttpModule to replace the built-in ASP.NET Session
object? I want to write a HttpModule that will handle storing and retrieving
of session values from an external database.

For example, when a page set values to Session object such as
Session("somevar")=1 then I want my HttpModule to get notified and store the
value into the external database. The same for "getting" the variable, I
want my own HttpModule to retrieve the values from the database.

Any pointers to code samples or tutorials are much appreciated.

Dan
Nov 19 '05 #1
4 3890
Danny W wrote:
Hi There!

Is it possible to use HttpModule to replace the built-in ASP.NET
Session object? I want to write a HttpModule that will handle storing
and retrieving of session values from an external database.

For example, when a page set values to Session object such as
Session("somevar")=1 then I want my HttpModule to get notified and
store the value into the external database. The same for "getting"
the variable, I want my own HttpModule to retrieve the values from
the database.
Any pointers to code samples or tutorials are much appreciated.

Dan


What is wrong (read: why do you want something different) with storing
the session-state in sqlserver, which is already supported?

By the way: It's not an "HttpModule", as those handle incoming requests.

Hans Kesting
Nov 19 '05 #2
Hi Hans,

Well, I do not have SQL Server and I do not have enough $$$ to buy one.
Besides, creating your own gives you more control and flexibility you need.

Any help on my question? :)

Cheers,
Dan

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:et****************@TK2MSFTNGP14.phx.gbl...
Danny W wrote:
Hi There!

Is it possible to use HttpModule to replace the built-in ASP.NET
Session object? I want to write a HttpModule that will handle storing
and retrieving of session values from an external database.

For example, when a page set values to Session object such as
Session("somevar")=1 then I want my HttpModule to get notified and
store the value into the external database. The same for "getting"
the variable, I want my own HttpModule to retrieve the values from
the database.
Any pointers to code samples or tutorials are much appreciated.

Dan


What is wrong (read: why do you want something different) with storing
the session-state in sqlserver, which is already supported?

By the way: It's not an "HttpModule", as those handle incoming requests.

Hans Kesting

Nov 19 '05 #3
Vko
I never try to do this but, I think you must :

1 /
remove the default session state module in the configuration file
add your own session state module

<httpModules>
<add type="Foo.MySessionState" name="MySession"/>
<remove name="Session"/>
</httpModules>

2 / Create your own SessionState module by implementing the IHttpModule
interface. I suggest you to use Reflector to see default session state (class
SessionStateModule) management.

"Danny W" wrote:
Hi Hans,

Well, I do not have SQL Server and I do not have enough $$$ to buy one.
Besides, creating your own gives you more control and flexibility you need.

Any help on my question? :)

Cheers,
Dan

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:et****************@TK2MSFTNGP14.phx.gbl...
Danny W wrote:
Hi There!

Is it possible to use HttpModule to replace the built-in ASP.NET
Session object? I want to write a HttpModule that will handle storing
and retrieving of session values from an external database.

For example, when a page set values to Session object such as
Session("somevar")=1 then I want my HttpModule to get notified and
store the value into the external database. The same for "getting"
the variable, I want my own HttpModule to retrieve the values from
the database.
Any pointers to code samples or tutorials are much appreciated.

Dan


What is wrong (read: why do you want something different) with storing
the session-state in sqlserver, which is already supported?

By the way: It's not an "HttpModule", as those handle incoming requests.

Hans Kesting


Nov 19 '05 #4
you can use the free version of sqlserver (msde). the session manager just
calls two procs, so you can easily change them.

-- bruce (sqlwork.com)

"Danny W" <dw@nospam.com> wrote in message
news:eY****************@TK2MSFTNGP12.phx.gbl...
| Hi Hans,
|
| Well, I do not have SQL Server and I do not have enough $$$ to buy one.
| Besides, creating your own gives you more control and flexibility you
need.
|
| Any help on my question? :)
|
| Cheers,
| Dan
|
| "Hans Kesting" <ne***********@spamgourmet.com> wrote in message
| news:et****************@TK2MSFTNGP14.phx.gbl...
| > Danny W wrote:
| >> Hi There!
| >>
| >> Is it possible to use HttpModule to replace the built-in ASP.NET
| >> Session object? I want to write a HttpModule that will handle storing
| >> and retrieving of session values from an external database.
| >>
| >> For example, when a page set values to Session object such as
| >> Session("somevar")=1 then I want my HttpModule to get notified and
| >> store the value into the external database. The same for "getting"
| >> the variable, I want my own HttpModule to retrieve the values from
| >> the database.
| >> Any pointers to code samples or tutorials are much appreciated.
| >>
| >> Dan
| >
| > What is wrong (read: why do you want something different) with storing
| > the session-state in sqlserver, which is already supported?
| >
| > By the way: It's not an "HttpModule", as those handle incoming requests.
| >
| > Hans Kesting
| >
|
|
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marcus | last post by:
Hi I have a large database with text strings. What is the quickest way to replace each with a throughout the database fields while leaving everything else intact? ex .... I'm a monkey...
0
by: Nick | last post by:
My HttpModule is only executing on the first run of the application? What would cause this to happen? This is a module that I am using to Authenticate requests instead of a Global.asax. This is...
1
by: Peter Rilling | last post by:
Can an HttpHandler or HttpModule be invoked on non-ASP.NET pages such as images or ASP or HTML pages? Can I trap a request for those pages? If not, how might I trap those requests?
2
by: don smolen | last post by:
I know that we can perform authentication of .aspx pages with an HttpModule, and that the same module can probably be used for static content (.htm, .jpg, etc.) by sending them through the ASP.Net...
3
by: parthivjoshi | last post by:
Do anyone have the idea how to add progressbar to the existing HTTPModule and HTTPApplication for File Upload. ********************************************************************** Sent via...
3
by: Adam | last post by:
Its my understanding that in asp.net 2.0 you can write an httpmodule that will acts as a wildcard handler and pass requests on to the proper engine, for instance, asp or perl for example, In the...
2
by: craigkenisston | last post by:
I have an asp.net application. This have a very special class that I use all over the site code. I also have an HttpModule which has been working quite fine. Now, due a strange requirement I need...
3
by: Erik Cruz | last post by:
Hi. I wrote an HTTPModule to log errors from my application. The component works well on all the development machines running Windows XP or Windows 2000 and VS.NET 2003. When I run the...
0
by: Fabio R. | last post by:
Hi, is there a way to have an HttpModule working also if the page has the OutputCache directive (<%@ OutputCache Duration="60" VaryByParam="none"%>)? I use an HttpModule to check some access...
4
by: Bac2Day1 | last post by:
I've got a HTTPMODULE that I need to be included on some pages within my site, but not others. This will allow security (the purpose of the module) on most parts of my site, but I need to bypass...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.