views:

478

answers:

2

I need access to session in httpmodule. It works fine when my page is a aspx page, but context.session is null when the request url is .html I have .html mapped to use aspnet_isapi.dll

I am trying to access session in context_PreRequestHandlerExecute and I have httpmodule inherit IReadOnlySessionState

+1  A: 

From my experience IReadOnlySessionState and IRequiresSessionState only apply to HttpHandlers.

See the following SO links on how to implement it:

Can I access session state from an HTTPModule?

IIS HttpModule unable to set Session

Paul
A: 

It does not work with HTML extension because aspnet_isapi.dll does not handle the extension, but handels .aspx pages.

You should use another extension instead of using HTML and you should register the new extension in IIS Application Configuration (Web Site Properties -> Home Directory tab -> Configuration button -> Mappings tab). Use .aspx as an example to add your own extension.

Antipod