views:

110

answers:

1

I have ASHX HTTPHandler which implements IRequiresSessionState. When I call this handler, and call aspx page of same application in another window, aspx page does not start processing until ashx page finishes processing. Even call to same ashx page from two different windows show that page which gets called first executes and then the next one.

When I do not implement IRequiresSessionState, pages load asynchronously without waiting for other page to complete.

This could be serious bottleneck for end user, who would like to work in multiple windows.

Session have user specific data. If above approach does not work, need alternative way to store user specific data for session, which can be used in HTTPHandler.

Other Info: - Am using ashx handler to process and send file which needs Session internally.

+1  A: 

session state access requires that the aspx pages, and handler, run sequentially. Each page/handler may read from and write to the session state. To handle this without creating any errors in the session state .net will only run one at a time. As Darin suggested, running with the read only session state will improve the situation. Asp.net will allow multiple handlers to run at the same time if they require only read access. However, the page will require write access to the session, so no handlers will run when the aspx page itself is running. This is the standard multi-reader single-writer locking pattern. You can have multiple readers at the same time, but only a single writer.

The only way to make this work is to have the handlers not require session state so that they run at the same time that t he aspx page is running.

You can work around this, by finding another way to store this data instead of using session state. You can implement your own shared cache/data structure, but you will need to provide similar locking (multi-reader/single writer) for that structure as well.

Mike
so I believe this will lock page processing only for that session where processing is going on with handler. Other user should be able to access page without waiting. Is it correct?
BigBoss
Yes. This is a session based lock, and will only block other requests that use the same session. Other users with different sessions will be able to access that same page without blocking.
Mike