<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PTOM: Breaking Free from HttpContext</title>
	<atom:link href="http://lostechies.com/colinramsay/2009/05/05/breaking-free-from-httpcontext/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/colinramsay/2009/05/05/breaking-free-from-httpcontext/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Wed, 27 May 2009 23:01:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: mycall</title>
		<link>http://lostechies.com/colinramsay/2009/05/05/breaking-free-from-httpcontext/#comment-85</link>
		<dc:creator>mycall</dc:creator>
		<pubDate>Wed, 27 May 2009 23:01:09 +0000</pubDate>
		<guid isPermaLink="false">/blogs/colin_ramsay/archive/2009/05/05/breaking-free-from-httpcontext.aspx#comment-85</guid>
		<description>Here is another workaround to embedding HttpContext.Current.Session..

    public class ContextStorage
    {

        [ThreadStatic]
        private static Dictionary&lt;string, object&gt; threadContext = new Dictionary&lt;string, object&gt;();

        public static bool IsWebContext()
        {
            try
            {
                return (HttpContext.Current != null);
            }
            catch (HttpException) { }
            return false;
        }

        public static IDictionary Items
        {
            get
            {
                return IsWebContext() ? HttpContext.Current.Items : threadContext;
            }
        }

    }</description>
		<content:encoded><![CDATA[<p>Here is another workaround to embedding HttpContext.Current.Session..</p>
<p>    public class ContextStorage<br />
    {</p>
<p>        [ThreadStatic]<br />
        private static Dictionary<string , object> threadContext = new Dictionary</string><string , object>();</p>
<p>        public static bool IsWebContext()<br />
        {<br />
            try<br />
            {<br />
                return (HttpContext.Current != null);<br />
            }<br />
            catch (HttpException) { }<br />
            return false;<br />
        }</p>
<p>        public static IDictionary Items<br />
        {<br />
            get<br />
            {<br />
                return IsWebContext() ? HttpContext.Current.Items : threadContext;<br />
            }<br />
        }</p>
<p>    }</string></p>
]]></content:encoded>
	</item>
</channel>
</rss>
