473,398 Members | 2,335 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,398 software developers and data experts.

SessionState in HttpModule problem (2.0)

Hello Developers,

I have an interesting problem. How, or when can I access SessionState from
HttpModule?
It seems that session state is only available when *.aspx page is requested.
It is not available for other resource types like *.gif files etc.

Is there any way I can force session state to load, even when it is not
*.aspx page being requested?

Thank you,
Tomasz J
Apr 12 '07 #1
7 2974
It is off by default, change your declaration

public class MyClass : IHttpHandler, IRequiresSessionState

"Tomasz" <oe****@nospam.nospamwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
Hello Developers,

I have an interesting problem. How, or when can I access SessionState from
HttpModule?
It seems that session state is only available when *.aspx page is
requested. It is not available for other resource types like *.gif files
etc.

Is there any way I can force session state to load, even when it is not
*.aspx page being requested?

Thank you,
Tomasz J

Apr 12 '07 #2
Thanks, but I am talking about HttpModule, not HttpHandler.

"Aidy" <ai**@noemail.xxxa.comwrote in message
news:A4******************************@bt.com...
It is off by default, change your declaration

public class MyClass : IHttpHandler, IRequiresSessionState

"Tomasz" <oe****@nospam.nospamwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
>Hello Developers,

I have an interesting problem. How, or when can I access SessionState
from HttpModule?
It seems that session state is only available when *.aspx page is
requested. It is not available for other resource types like *.gif files
etc.

Is there any way I can force session state to load, even when it is not
*.aspx page being requested?

Thank you,
Tomasz J


Apr 12 '07 #3
Hi Tomasz,

By default, *.gif files are served by IIS, not the aspnet_isapi.dll (like
*.aspx); and the Session State is loaded by SessionStateModule, which is a
built-in HttpModule, you can find it's configured in system-wide web.config
such as:

<httpModules>
<add name="OutputCache"
type="System.Web.Caching.OutputCacheModule" />
<add name="Session"
type="System.Web.SessionState.SessionStateModule" />
<add name="WindowsAuthentication"
type="System.Web.Security.WindowsAuthenticationMod ule" />

...
If you need to load session state when user is requesting *.gif files, you
must configure IIS to serve *.gif files via aspnet_isapi.dll; however,
please note serving static content via aspnet_isapi.dll is not effective as
serving via IIS.

Hope this helps.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 13 '07 #4
Thank you Walter, but I am not quite sure I understand.
It looks like those "static content" requests, somehow, involve
aspnet_isapi.dll. All the events like BeginRequest, AuthorizeRequest or
AcquireRequestState fire. It is just that the HttpContext.Current.Session is
null.

What I am trying to develop is a special kind of rewrite engine. It must
have access to the session state and I cannot modify system-wide web.config
settings - the application is supposed to work in shared hosting
environment.

Do you think it can be done using HttpHandler? If so, where/when do I have
to call Context.RewritePath() method?

Thank you,

Tomasz J

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:GF**************@TK2MSFTNGHUB02.phx.gbl...
Hi Tomasz,

By default, *.gif files are served by IIS, not the aspnet_isapi.dll (like
*.aspx); and the Session State is loaded by SessionStateModule, which is a
built-in HttpModule, you can find it's configured in system-wide
web.config
such as:

<httpModules>
<add name="OutputCache"
type="System.Web.Caching.OutputCacheModule" />
<add name="Session"
type="System.Web.SessionState.SessionStateModule" />
<add name="WindowsAuthentication"
type="System.Web.Security.WindowsAuthenticationMod ule" />

..
If you need to load session state when user is requesting *.gif files, you
must configure IIS to serve *.gif files via aspnet_isapi.dll; however,
please note serving static content via aspnet_isapi.dll is not effective
as
serving via IIS.

Hope this helps.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Apr 13 '07 #5
I just came across this great post by Mike Volodarsky, IIS Core Server /
ASP.NET Runtime Program Manager

https://forums.iis.net/thread/1648944.aspx

It looks like it is a known issue and whether or not session state is
available is actually decided... by the SessionStateModule itself!

Tomasz J
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:GF**************@TK2MSFTNGHUB02.phx.gbl...
Hi Tomasz,

By default, *.gif files are served by IIS, not the aspnet_isapi.dll (like
*.aspx); and the Session State is loaded by SessionStateModule, which is a
built-in HttpModule, you can find it's configured in system-wide
web.config
such as:

<httpModules>
<add name="OutputCache"
type="System.Web.Caching.OutputCacheModule" />
<add name="Session"
type="System.Web.SessionState.SessionStateModule" />
<add name="WindowsAuthentication"
type="System.Web.Security.WindowsAuthenticationMod ule" />

..
If you need to load session state when user is requesting *.gif files, you
must configure IIS to serve *.gif files via aspnet_isapi.dll; however,
please note serving static content via aspnet_isapi.dll is not effective
as
serving via IIS.

Hope this helps.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Apr 14 '07 #6
Hi Tomasz,

Thank you for sharing the URL and I'm glad you've found the
workaround/solution.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 16 '07 #7
Hello Walter,

Here is a brief description of the solution I implemented.

In order to force session state to load, the current Context.Handler,
usually DefaultHttpHandler, has to be replaced in the PostMapRequestHandler
event by some other handler, implementing IRequiresSessionState. To be safe,
my dummy handler implementing IRequiresSessionState also carries a reference
to the original handler, and I swap it back in the PostAcquireRequestState
event, once the dummy handler fulfilled its mission between those two
events.

Regards,

Tomasz J

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:jn****************@TK2MSFTNGHUB02.phx.gbl...
Hi Tomasz,

Thank you for sharing the URL and I'm glad you've found the
workaround/solution.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Apr 16 '07 #8

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

Similar topics

0
by: Bruce B | last post by:
Hi group, I'm experiencing some extreme weirdness over the last week with IIS related to it's Mappings and how .NET is behaving. I can't explain the behavior as it seems very random. Our...
7
by: nail | last post by:
Folks, I develop a HttpModule and it works correct, but one problem is occurs. After I register the httpmodule in the web.config, my pages (not testing http://localhost/site but...
4
by: Danny W | last post by:
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...
2
by: Simon-Pierre Jarry | last post by:
Hi, I created a custom HttpModule for managing the security of my application. in "Init" sub, I regsiter the events doing that : Public Sub Init(ByVal context As System.Web.HttpApplication)...
2
by: walter | last post by:
Hi there, I know there is pool of HttpApplications, and for each request coming in, HttpRuntime will dedicate one from pool to serve the request. My questions are : 1. since HttpModule is plug...
1
by: Faraz | last post by:
Hi everyone, I am running into a slight problem. My understanding is that a custom HttpModule will run for every request made to the server, regardless of the extension. I do not experience this...
0
by: mattdev1000 | last post by:
Hello, I have an HttpModule that uses a lazy fetch to a secondary tier for calculating some values (the calculation is can be multisecond in the worse case). The HttpModule spins up a thread to...
0
by: somnathmali | last post by:
Suppose I have site xyz.com. Site has a page called show_user.aspx where I need to access the Session variables. But this show_user.aspx page will not be called directly Instead , when user type...
3
by: Joseph Geretz | last post by:
I'm implementing a web application whose purpose in life is to act as a data conduit. Data is posted to my Web app in XML format, my application examines the data and forwards it onward by posting...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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,...
0
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...

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.