473,661 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IHttpModule Question (storing state)

I've created a custom IHttpModule that does custom authentication.
Currently it stores authenticated user info in a hashtable within the
class so I don't have to re-authenticate against a database everytime a
logged in user hits a page.

So far, it works great.

Here is my question, is my approach for storing logged in users
correct? Meaning, can I be sure that only one instance of my
IHttpModule will be created for my Application. So far, in testing,
this seems to be the case, but I have yet to do any hardcore multiuser
testing. If more than one instance is created, my method of storing
logged in users will fail because each instance will have its own
hashtable.

So if that is the case, I figure I'll make the hashtable static. Does
anyone see any downside to this?
Thanks for your help

Nov 19 '05 #1
4 1844
There will be many instances of your HttpModule withint the application.
ASP.NET creates and maintains a pool of HttpApplication/HttpModules tuples
for servicing requests when the arrives in ASP.NET. So any one instance of
your HttpModule will be thread safe, but shared data won't be. Also, if you
want to cache/share data among them then static variables are an option,
but so is the ASP.NET data Cache. The first part of this article talks about
threading and the app/modules pooled in the HttpPipeline:

http://msdn.microsoft.com/msdnmag/is...g/default.aspx

-Brock
DevelopMentor
http://staff.develop.com/ballen
I've created a custom IHttpModule that does custom authentication.
Currently it stores authenticated user info in a hashtable within the
class so I don't have to re-authenticate against a database everytime
a logged in user hits a page.

So far, it works great.

Here is my question, is my approach for storing logged in users
correct? Meaning, can I be sure that only one instance of my
IHttpModule will be created for my Application. So far, in testing,
this seems to be the case, but I have yet to do any hardcore multiuser
testing. If more than one instance is created, my method of storing
logged in users will fail because each instance will have its own
hashtable.

So if that is the case, I figure I'll make the hashtable static. Does
anyone see any downside to this?

Thanks for your help


Nov 19 '05 #2
Hello Mike,

I think you do have to make it static. I believe that if you put a ctor on
your on your HttpModule, you'll see that its recreated.

--
Matt Berther
http://www.mattberther.com
I've created a custom IHttpModule that does custom authentication.
Currently it stores authenticated user info in a hashtable within the
class so I don't have to re-authenticate against a database everytime
a logged in user hits a page.

So far, it works great.

Here is my question, is my approach for storing logged in users
correct? Meaning, can I be sure that only one instance of my
IHttpModule will be created for my Application. So far, in testing,
this seems to be the case, but I have yet to do any hardcore multiuser
testing. If more than one instance is created, my method of storing
logged in users will fail because each instance will have its own
hashtable.

So if that is the case, I figure I'll make the hashtable static. Does
anyone see any downside to this?

Thanks for your help

Nov 19 '05 #3
Brock,

Thanks for the reply. I'd like to use built in ASP.NET cache, but
since I am doing my processing in the AuthenticateReq uest event, I was
under the impression that built in session and other caching mechinisms
are not available. Is this correct?

Nov 19 '05 #4
The data Cache is different from Session. You're right that in the AuthenticateReq uest
event Session is not yet available, but the data Cache is. I'd use the data
Cache.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Brock,

Thanks for the reply. I'd like to use built in ASP.NET cache, but
since I am doing my processing in the AuthenticateReq uest event, I
was under the impression that built in session and other caching
mechinisms are not available. Is this correct?


Nov 19 '05 #5

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

Similar topics

0
1171
by: moid | last post by:
Sir we are implementing front controller in asp.net. we implement three event-handler 1. PreRequestHandlerExecute 2. PostRequestHandlerExecute 3. BeginRequest we just want to initialize the page, but dont want to load it. After BeginReq the page should Load. becuse we need to fill Datagrid through Command
2
2369
by: Kenneth Myhra | last post by:
Hi, We have been trying to develop an IHTTPModule (that was supposed to replace or take over the ISAPI Filters, as far as we know). We have developed one in C# and it seems to be working. The problem is that it is not working as it is supposed to work and we *need* to debug it. We made a search on MSDN already. Either my search keywords were irrelevant (we used <IHTTPModule debug> and <IHTTPModule debugging>, without the greater and...
2
1423
by: Kenneth Myhra | last post by:
Hi, We are trying to make an authorization module for our web dav folder using ..NET and implementing the IHttpModule. We have already done this in a previous version of our product, with an ISAPI filter (written in c++), but now we want to move it to .NET. We are almost where we want to be, by implementing the IHttpModule interface we can almost do our own custom authorization, but we need to get a hold of the verbs GET and PUT when...
2
1642
by: Kenneth Myhra | last post by:
Hi all, We are trying to make an ISAPI Filter, in .NET by implementing the IHttpModule interface, that will authorize the request for certain binary file types (GET), this is working fine. But we also want it to authorize the upload of binary files (PUT), The problem with the PUT-scenario is that the file is *not* uploaded when its extension *is* mapped up in IIS, by mapped up I mean the Application Mappings displayed when clicking on the...
5
2362
by: Andrew Lippitt | last post by:
What gaurantees are there in the way of which thread the events are called from. I've seen: Thread A Begin Thread B Begin Thread A End Thread A End That seems to indicate that Begin and End can't be assumed to be called from the same thread, but can I assume that the Begin will happen on the same thread that executes the request?
6
1397
by: Andy G | last post by:
I am trying to implement the global error handling described on this page... http://www.dotnetdevs.com/articles/GlobalErrorHandling.aspx I'm a VB person and don't understand much of C# when it gets more complicated. Can someone please help me with the following statement that is in C#, I need this in VB and have been using Patel's converter but just can't get rid of the errors in VS.NET. void IHttpModule(HttpApplication application) {...
6
4169
by: Simone Busoli | last post by:
Hello, I am trying to understand when IHttpModule.Dispose method is called. Is it called when the Application is disposed, or when the request ends? If I want to make an object Application-wide and close it when the application ends can I use that method or write something like this in the class that implements the IHttpModule? public void Init(HttpApplication application) { application.Disposed +=new...
8
2920
by: =?Utf-8?B?UGhpbGlw?= | last post by:
When is the IHttpModule Dispose driven ?....at application recycle time ? I developed a test HttpModule to trace INIT, BeginRequest, EndRequest and Dispose....and the Dispose never gets driven. After a while the INIT is redriven however the Dispose was never driven. I am trying to locate the best means to hook ASP.NET application recycling ...... Is IHttpModule Dispose a solution for this and if so how ?...... or should I use...
1
1464
by: Eric Goforth | last post by:
Hello, I found a C# example on the web that used an httpmodule. I've translated it to VB.NET and the website compiles fine, but when I build the website the iHttpModule doesn't compile, I can't figure out why. I do have the following entry in my web.config file: <system.web><httpModules><add name="MyModule" type="MyModule.MyModule"/ My iHttpModule Class implements iHttpModule (of course). I also have
0
8754
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.