How to manipulate Session in Http Handlers

There is a common issue that you can’t manipulate session objects in http handlers, the files with ASHX extension 🙂 Well normally you can read the contents in the session via context.Session but you can add/remove/modify that in there. So how do you do this:

The answer is simple: Just implement the IRequiresSessionState interface. It doesnt have any method to implement so you dont have to worry about any details, this just notifies the runtime that Session can be manipulated in this context. So your class declaration would look something like this:-

public class SetLabels : IHttpHandler, IRequiresSessionState


Author: Imran Akram

A .NET/SharePoint Consultant and a political enthusiast who believes in putting the feet of the elected and/or unelected officials to fire in order to get good governance.

One thought on “How to manipulate Session in Http Handlers”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s