<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Interacting with session state from InfoPath</title><link>https://www.infopathdev.com:443/forums/thread/86406.aspx</link><pubDate>Fri, 25 Jan 2013 12:40:21 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:86406</guid><dc:creator>Poolio</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/86406.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=86406</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;I&amp;#39;ve got a browser-enabled InfoPath 2013 form hosted in SharePoint 2013, with some code behind that interacts with the ASP.Net session state. I&amp;#39;ve enabled the SharePoint session state service (SQL Server mode) and configured the web.config to enable session state.&lt;/p&gt;&lt;p&gt;At the moment the form just has a button with one line of code which executes onClick:&lt;/p&gt;&lt;font color="#008000" size="2" face="Consolas"&gt;&lt;font color="#008000" size="2" face="Consolas"&gt;&lt;font color="#008000" size="2" face="Consolas"&gt;&lt;p&gt;HttpContext.Current.Session.Add(&amp;quot;Foo&amp;quot;, &amp;quot;1&amp;quot;);&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;This should create a session state&amp;nbsp;variable called &amp;quot;Foo&amp;quot; with a value of 1 when the button is clicked.&lt;/p&gt;&lt;p&gt;However the code fails with an &amp;quot;Object reference not set to an instance of an object&amp;quot; error. I put some checks into the code to see what was going on, and it transpires that &lt;strong&gt;HttpContext.Current.Session &lt;/strong&gt;is coming back null.&lt;/p&gt;&lt;p&gt;Does anyone have any ideas why this might be?&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;&lt;p&gt;Anthony&lt;/p&gt;</description></item></channel></rss>