Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
Accessing Session from an HttpHandler
travislaborde
follow
1
7-30-2007 8:29 AM
698 views
tags:
programming
,
asp.net
,
httphandler
1 Comment
|
Add a Comment
7-30-2007
3:46 PM
BitDrifter
Great clips, thanks.
Login
to Comment. Not a member yet?
Sign up
Related Clips
The Age of Thinking, Self-Developing Robot...
Alan Colmes to Depart Top Rated Hannity & ...
Immersive Data Exploration
Sean Hannity Losing Colmes
MPAA Seeks To Render Obsolete Millions Of ...
CNN Retool Includes Christian Amanpour..Da...
Radio Paradise - listener-supported eclect...
More clips from
travislaborde
THE SPOILED UNDER-30 CROWD!!!
40 Wallpapers Loaded With Color
Wallpaper: Elemental
Today's Top Clips
Humanity May Hold Key For Next Earth Evolution
Quaker statement on gay marriage
After Seven Years, Guantánamo Prisoners Need to be Tried or Released
"No Child Left Behind" a "Trojan Horse" for Pentagon Recruiters
Addicts and Homeless Perceived As Objects
The Most Mysterious Manuscript: The Voynich or Cipher Manuscript
Memories may be stored on your DNA
Bush Takes a Last-Minute Swipe at Workers' Rights
The Onion - They tried to teach my baby Science!
'Non-genital Orgasms" - Orgasms that have nothing to do with the genitalia
visit the
Top Clips page
View the Top Clips from
July 30, 2007
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/e0f9d960-2e8f-47d2-9770-dd8fd2af2084/172DF021-80C0-48C9-B900-665C9D70F080/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx" href="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx" style="font-size: 11px;">aspadvice.com</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx"><H2>Accessing Session from an HttpHandler</H2></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx"><P>I've run into this before but forgotten about it. I wrote an HttpHandler recently and was trying to access the Session object from the passed in HttpContext context object with </P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx"><P><STRONG>context.Session["foo"] = "bar";</STRONG> </P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx">and I encountered a <STRONG>NullReferenceException</STRONG>. </blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx">in order to access Session from an HttpHandler you need to add a marker interface (meaning an interface with no implementation requirements) to your HttpHandler class. </blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx"><P>There are in fact several options you can choose from, and it's best for performance reasons if you limit your selection to only what is needed. The marker interfaces are found in the <A href="http://msdn2.microsoft.com/en-us/library/system.web.sessionstate(vs.80).aspx">System.Web.SessionState</A> namespace, and include the following:</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx"><P><STRONG><A href="http://msdn2.microsoft.com/en-us/library/system.web.sessionstate.irequiressessionstate(VS.80).aspx">IRequiresSessionState</A></STRONG> - Specifies the HTTP handler requires both read and write access to session state values.</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://aspadvice.com/blogs/ssmith/archive/2007/07/29/accessing-session-from-an-httphandler.aspx"><P><STRONG><A href="http://msdn2.microsoft.com/en-us/library/system.web.sessionstate.ireadonlysessionstate(VS.80).aspx">IReadOnlySessionState</A></STRONG> - Specifies the HTTP handler requires only read access to session state values.</P></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/172DF021-80C0-48C9-B900-665C9D70F080/blog/" title="blog or email this clip"><img src="http://content6.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Blog
Copyright
Privacy
EULA
OK