<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>Makiwa &#187; ASP.NET</title>
	<link>http://www.makiwa.com</link>
	<description>Stuart Campbell's occasional musings about software development, etc.</description>
	<pubDate>Thu, 08 May 2008 11:04:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>FormsAuthentication.Encrypt returns null</title>
		<link>http://www.makiwa.com/index.php/2007/02/13/formsauthenticationencrypt-returns-null/</link>
		<comments>http://www.makiwa.com/index.php/2007/02/13/formsauthenticationencrypt-returns-null/#comments</comments>
		<pubDate>Tue, 13 Feb 2007 11:27:53 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2007/02/13/formsauthenticationencrypt-returns-null/</guid>
		<description><![CDATA[I was writing some ASP.NET authentication code last night and was trying to encrypt an authentication ticket using FormsAuthentication.Encrypt(). However, it kept returning null. I banged my head against the wall for about an hour and then went home. As so often happens, I came in in the morning and spotted the problem immediately: the [...]]]></description>
			<content:encoded><![CDATA[<p>I was writing some ASP.NET authentication code last night and was trying to encrypt an authentication ticket using FormsAuthentication.Encrypt(). However, it kept returning null. I banged my head against the wall for about an hour and then went home. As so often happens, I came in in the morning and spotted the problem immediately: <strong>the authentication ticket's user data was null</strong>. Doh! I had only put null in there for test purposes!</p>
<div class="igBar"><span id="lcsharp-2"><a href="#" onclick="javascript:showPlainTxt('csharp-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-2">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FormsAuthenticationTicket authTicket =</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> FormsAuthenticationTicket<span style="color: #000000;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;color:#800000;">1</span>, <span style="color: #008080; font-style: italic;">// version</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">"stu@me.com"</span>, <span style="color: #008080; font-style: italic;">// email</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; DateTime.<span style="color: #0000FF;">Now</span>, <span style="color: #008080; font-style: italic;">// creation</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; DateTime.<span style="color: #0000FF;">Now</span>.<span style="color: #0000FF;">AddMinutes</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">60</span><span style="color: #000000;">&#41;</span>,<span style="color: #008080; font-style: italic;">// Expiration</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">false</span>, <span style="color: #008080; font-style: italic;">// Persistent</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// User data (TICKET WON'T BE ENCRYPTED IF THIS IS NULL)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">string</span> encryptedTicket = FormsAuthentication.<span style="color: #0000FF;">Encrypt</span><span style="color: #000000;">&#40;</span>authTicket<span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2007/02/13/formsauthenticationencrypt-returns-null/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ASP.NET web.config intellisense stops working in VS2005</title>
		<link>http://www.makiwa.com/index.php/2006/04/30/aspnet-webconfig-intellisense-stops-working-in-vs2005/</link>
		<comments>http://www.makiwa.com/index.php/2006/04/30/aspnet-webconfig-intellisense-stops-working-in-vs2005/#comments</comments>
		<pubDate>Sun, 30 Apr 2006 10:44:32 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2006/04/30/aspnet-webconfig-intellisense-stops-working-in-vs2005/</guid>
		<description><![CDATA[This has been really annoying me recently. Thank goodness Scott Guthrie explains how to fix it.
]]></description>
			<content:encoded><![CDATA[<p>This has been really annoying me recently. Thank goodness <a title="VS 2005 Intellisense in web.config files" href="http://weblogs.asp.net/scottgu/archive/2005/12/02/432077.aspx" target="_blank">Scott Guthrie explains how to fix it</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2006/04/30/aspnet-webconfig-intellisense-stops-working-in-vs2005/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Define the location of ASP.NET client validation scripts</title>
		<link>http://www.makiwa.com/index.php/2005/06/02/define-the-location-of-aspnet-client-validation-scripts/</link>
		<comments>http://www.makiwa.com/index.php/2005/06/02/define-the-location-of-aspnet-client-validation-scripts/#comments</comments>
		<pubDate>Thu, 02 Jun 2005 15:53:37 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/?p=13</guid>
		<description><![CDATA[Over the weekend a bank went live with a system I've been working on for the last year. The system is now in production and things are running smoothly, but that is not to say there weren't any hitches.
The one problem was that the submit button on ASP.NET pages does not work after you install [...]]]></description>
			<content:encoded><![CDATA[<p>Over the weekend a bank went live with a system I've been working on for the last year. The system is now in production and things are running smoothly, but that is not to say there weren't any hitches.</p>
<p>The one problem was that <a target="_blank" href="http://support.microsoft.com/Default.aspx?kbid=889877">the submit button on ASP.NET pages does not work after you install the .NET Framework 1.1 Service Pack 1</a>. The solution didn't seem too difficult. Just call <strong><code>aspnet_regiis -c</code></strong> and all will be right with the world. That solution would usually work well: it would replace the following erroneous code in WebUIValidation.js:<br />
<div style="font-family:Courier New; white-space:pre-wrap;"><br />
<span class="mcsh_blue">function</span> ValidatorCommonOnSubmit() {<br />
    event.returnValue = !Page_BlockSubmit;<br />
    Page_BlockSubmit = <span class="mcsh_blue">false</span>;<br />
}<br /></div><br />
with the following correct code...<br />
<div style="font-family:Courier New; white-space:pre-wrap;"><br />
<span class="mcsh_blue">function</span> ValidatorCommonOnSubmit() {<br />
    <span class="mcsh_blue">var</span> result = !Page_BlockSubmit;<br />
    Page_BlockSubmit = <span class="mcsh_blue">false</span>;<br />
    event.returnValue = result;<br />
    <span class="mcsh_blue">return</span> result;<br />
}<br /></div></p>
<p>However, after doing this the problem was still there. The submit button still failed, but a search of every WebUIValidation.js file on the server proved that the correct versions were in place. I was also able to prove (by hacking the URL) that the old script file was definitely being downloaded to the client! So where was it coming from? <img src='http://www.makiwa.com/wp-includes/images/smilies/icon_confused.gif' alt=':?' class='wp-smiley' /> </p>
<p>The answer is that the file was coming from a completely different server because of the bank's VirtualVault security software (basically, the server to which the root IP address mapped was not the server to which the virtual directory mapped). We now had a problem because we did not have access to the other server and so we could not apply the fix.</p>
<p>The solution was obviously to tell the browser to look elsewhere for the client validation scripts. By default, the browser gets the script from the root relative path:<br />
<code><br />
/aspnet_client/system_web/1_1_4322/WebUIValidation.js<br />
</code><br />
This is defined in <strong><code>machine.config</code></strong> as follows:<br />
<div style="font-family:Courier New; white-space:pre-wrap;"><br />
&lt;system.web&gt;<br />
  &lt;webcontrols<br />
        <span class="mcsh_red;">clientScriptsLocation</span><span class="mcsh_red;"></span>=&quot;<span class="mcsh_blue">/aspnet_client/system_web/1_1_4322/</span>&quot;/&gt;<br />
&lt;/system.web&gt;<br /></div><br />
All I needed to do was to override this setting for our web application by adding the same setting to <strong><code>web.config</code></strong> and changing the path:<br />
<div style="font-family:Courier New; white-space:pre-wrap;"><br />
&lt;system.web&gt;<br />
  &lt;webcontrols<br />
<span class="mcsh_red;">clientScriptsLocation</span><span class="mcsh_red;"></span>=&quot;/{VirtualDir}/aspnet_client, etc.&quot;/&gt;<br />
&lt;/system.web&gt;<br /></div></p>
<p>I hope somebody else finds this useful (...when I get round to submitting this blog to the search engines).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2005/06/02/define-the-location-of-aspnet-client-validation-scripts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ASP.NET and Firefox</title>
		<link>http://www.makiwa.com/index.php/2005/05/24/aspnet-and-firefox/</link>
		<comments>http://www.makiwa.com/index.php/2005/05/24/aspnet-and-firefox/#comments</comments>
		<pubDate>Tue, 24 May 2005 09:23:15 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2005/05/24/aspnet-and-firefox/</guid>
		<description><![CDATA[I have been really struggling this morning with the way ASP.NET renders server controls for Firefox. It will render a Panel as a DIV under IE, but as a TABLE under Firefox.
I thought I was going to need to include different stylesheets for different browsers and I was getting kinda annoyed by it all because [...]]]></description>
			<content:encoded><![CDATA[<p>I have been really struggling this morning with the way ASP.NET renders server controls for Firefox. It will render a Panel as a DIV under IE, but as a TABLE under Firefox.<br />
I thought I was going to need to include different stylesheets for different browsers and I was getting kinda annoyed by it all because Firefox can easily handle DIVs.</p>
<p>And then I found this <a href="http://weblogs.asp.net/mrupp/archive/2003/04/03/4789.aspx">really helpful post</a> that caused the problem to disappear instantly.</p>
<p>Basically, the default browser capabilities (browsercaps) for Netscape-like browsers is to treat them as downlevel browsers. The post shows what you need to add to web.config to get Firefox and its ilk to be treated as the uplevel browsers that there are.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2005/05/24/aspnet-and-firefox/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
