Last post Mar 13, 2015 02:05 AM by whizkidgps
Mar 11, 2015 10:30 PM|whizkidgps|LINK
I've written custom httpmodule and it's being called up for every request. I want to store the value on my first request and this value needs to be retrieved for subsequent request. Is this possible in HttpModule?
I know HttpContext.Current.Items preserve the value only for single request and we cannot use Session in our project as per our requirements.
Do we have any other option apart from session\HttpContext.Current.Items for storing values in HttpModule?
Mar 12, 2015 09:50 PM|Shawn - MSFT|LINK
For this situation, you can share information throughout your application by using the
HttpApplicationState class, most commonly accessed through the
Application property of the
HttpContext object. This class exposes a key-value dictionary of objects that you can use to store both .NET Framework objects and scalar values related to multiple Web requests from multiple clients.
An instance of the HttpApplicationState class is created the first time any client requests a URL resource from within the virtual directory namespace of a particular ASP.NET application. This is the case for each Web application that is
stored on the computer. Access to this per-application instance is provided through an
HttpContext property named
Application. All HttpModules and HttpHandlers, such as an ASP.NET page, have access to an instance of the context and therefore have access to the
Application property during a given Web request.
For more information, you could refer to:
Mar 13, 2015 02:05 AM|whizkidgps|LINK
I understand HttpApplicationState is based on single user session and anyone can read and make update with in application boundary. But my requirement is some what different as per the behavior of HttpApplicationState.
I've written PostAuthenticateRequest event in my HttpModule and it's getting called up for each request.
context.PostAuthenticateRequest += new EventHandler(this.application_PostAuthenticateRequest);
My plan here is, On very first request, I need to identify authentication type
(AD\FBA) of my web application and it needs to be stored either session\cookies. So that, on sub sequent request authentication type will be retrieved from session\cookies instead of checking the authentication type for every web request.
Could you please help me to achieve above request instead of checking authentication type for every request?