<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/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>Web Forms</title><link>http://forums.asp.net/18.aspx</link><description>All about building ASP.NET Pages - server controls, events, validation, etc.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Using Session state to store objects</title><link>http://forums.asp.net/thread/1214643.aspx</link><pubDate>Thu, 02 Mar 2006 09:27:37 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1214643</guid><dc:creator>StrongTypes</dc:creator><author>StrongTypes</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1214643.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1214643</wfw:commentRss><description>&lt;p&gt;&lt;font face=Verdana size=2&gt;You'll need to do something like this:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" size=2&gt;SearchResultCollection ownerResults = Session[&lt;font color=#800000&gt;"ownerResults"&lt;/font&gt;] as SearchResultCollection; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" size=2&gt;if (ownerResults != null)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Code here&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=Verdana size=2&gt;HTH,&lt;br /&gt;Ryan&lt;/font&gt;&lt;/p&gt;</description></item><item><title>Using Session state to store objects</title><link>http://forums.asp.net/thread/1214638.aspx</link><pubDate>Thu, 02 Mar 2006 09:18:49 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1214638</guid><dc:creator>Benp - 81Consulting</dc:creator><author>Benp - 81Consulting</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1214638.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1214638</wfw:commentRss><description>&lt;span&gt;&lt;font face=Verdana&gt;Hi&lt;/font&gt;
&lt;p&gt;&lt;font face=Verdana&gt;I want to save an object, and make it available over several pages.&amp;nbsp; So far it seems the best way for me to do this is to use sessions.&amp;nbsp; However I can't find a way to store an object for the duration of a session.&amp;nbsp; Below is some of the code&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=Verdana&gt;&lt;strong&gt;Fragment of Method 1&lt;/strong&gt;&lt;/font&gt;&lt;font color=#008080 size=2&gt;
&lt;p&gt;SearchResultCollection&lt;font size=2&gt; ownerResults = &lt;em&gt;Code to return SearchResultCollection&lt;/em&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size=2&gt;
&lt;p&gt;Session[&lt;font color=#800000 size=2&gt;"ownerResults"&lt;/font&gt;&lt;font size=2&gt;] = ownerResults;&lt;/font&gt;
&lt;p&gt;&lt;font face=Verdana&gt;&lt;strong&gt;Fragment of Method 2&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;font color=#008080 size=2&gt;
&lt;p&gt;SearchResultCollection&lt;font size=2&gt; ownerResults = Session[&lt;/font&gt;&lt;font color=#800000 size=2&gt;"ownerResults"&lt;/font&gt;&lt;font size=2&gt;];&lt;/font&gt;
&lt;p&gt;&lt;font face=Verdana&gt;However, I get the following error&lt;/font&gt;.&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;Error&amp;nbsp;1&amp;nbsp;Cannot implicitly convert type 'object' to 'System.DirectoryServices.SearchResultCollection'. An explicit conversion exists (are you missing a cast?)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=Verdana&gt;My question is, how can I store an object, to be used by the same page, or different page in the same session?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=Verdana&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font face=Verdana&gt;Thanks&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=Verdana&gt;Ben&lt;/font&gt;&lt;/p&gt;&lt;/p&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/span&gt;</description></item></channel></rss>