<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.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>Ehsan Mahpour's Weblog</title>
	<link>http://mahpour.com/blog</link>
	<description>Sharing the experience</description>
	<pubDate>Mon, 03 Mar 2008 18:12:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3</generator>
	<language>en</language>
			<item>
		<title>How to redirect a web page, the smart way</title>
		<link>http://mahpour.com/blog/2008/03/03/how-to-redirect-a-web-page-the-smart-way-2/</link>
		<comments>http://mahpour.com/blog/2008/03/03/how-to-redirect-a-web-page-the-smart-way-2/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 18:12:22 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[HTML/CSS Tips]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2008/03/03/how-to-redirect-a-web-page-the-smart-way-2/</guid>
		<description><![CDATA[I posted an article from Steven Hargrove&#8217;s weblog&#160; about how to redirect a web page in correct way last week and he asked me to remove it from here since he would like to keep the credit of that.
In respect to his request I removed the article from my blog. just wanted to say that&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I posted an article from Steven Hargrove&#8217;s weblog&nbsp; about how to redirect a web page in correct way last week and he asked me to remove it from here since he would like to keep the credit of that.<br />
In respect to his request I removed the article from my blog. just wanted to say that&nbsp; I never steal content from other people without mentioning about the source of that in my blog.</p>
<p>Anyways, whoever is interested to read it can go to his weblog and read it. <a href="http://www.stevenhargrove.com/redirect-web-pages/" target="_blank">Click here</a></p>
<h2 id="post-30" class="posttitle"><a title="Permanent link to How to redirect a web page, the smart way" rel="bookmark" href="http://www.stevenhargrove.com/redirect-web-pages/"><br />
</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2008/03/03/how-to-redirect-a-web-page-the-smart-way-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The terminal server has exceeded the maximum number of allowed connections. The system cannot log you on (1B8E). Please try again or consult your system administrator.</title>
		<link>http://mahpour.com/blog/2007/12/13/the-terminal-server-has-exceeded-the-maximum-number-of-allowed-connections-the-system-cannot-log-you-on-1b8e-please-try-again-or-consult-your-system-administrator/</link>
		<comments>http://mahpour.com/blog/2007/12/13/the-terminal-server-has-exceeded-the-maximum-number-of-allowed-connections-the-system-cannot-log-you-on-1b8e-please-try-again-or-consult-your-system-administrator/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 14:55:28 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[Administration]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2007/12/13/the-terminal-server-has-exceeded-the-maximum-number-of-allowed-connections-the-system-cannot-log-you-on-1b8e-please-try-again-or-consult-your-system-administrator/</guid>
		<description><![CDATA[Yes! This is a solution to the dreaded problem “The
terminal server has exceeded the maximum number of allowed connections.”
&#160;
Every system administrator knows what it means, and yes –
it gives us shivers, especially when we don’t have physical acess to the
machine, and we can’t log in.
&#160;
There are (at least) two ways to solve the problem, the
easy [...]]]></description>
			<content:encoded><![CDATA[<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Yes! This is a solution to the dreaded problem “The<br />
terminal server has exceeded the maximum number of allowed connections.”</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Every system administrator knows what it means, and yes –<br />
it gives us shivers, especially when we don’t have physical acess to the<br />
machine, and we can’t log in.</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">There are (at least) two ways to solve the problem, the<br />
easy one and the hard one, as usual.</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">The <b>easy one</b> – applies if TS runs on a Windows 2003<br />
machine, and Console session is logged off but two active (or disconnected)<br />
sessions block further access.</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">From the client machine, go to <b>Start -&gt; Run </b>and<br />
type </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><b><span style="font-family: &quot;Courier New&quot;;">mstsc<br />
-v:0.0.0.0 /f –console</span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Replace 0.0.0.0 with TS server’s IP.</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">After you log in, go to Terminal Server Management and<br />
disconnect active, idle and other remote sessions. Logg of and then log on as<br />
you would normally do.</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">The <b>hard way</b> – applies in cases when the easy way<br />
fails (Windows 2000 runs as a TS server, Console session logged in, etc.)</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Conditions to be met for the hard way to succeed:</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;<br />
&nbsp; - telnet service must not be disabled on the TS machine, it must be set<br />
to either automatic or</span> <span style="font-size: 10pt; font-family: Verdana;">manual<br />
startup. <br />
&nbsp; - you must have the &#8220;netsvc.exe&#8221; tool from the windows 2000<br />
resource kit if you need to start telnet on the terminal&nbsp; services machine<br />
if it is not running. If you don’t have it, you can <a set="yes" linkindex="0" href="netsvc.zip">download<br />
it here</a>.</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Authenticate to the terminal server from the remote<br />
machine with the &#8220;net use&#8221; command: </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><b><span style="font-size: 10pt; font-family: Verdana;">Start-&gt;Run-&gt;cmd</span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 12pt;"><b><span style="font-family: &quot;Courier New&quot;;">C:\&gt;net use \\&lt;ip<br />
address&gt;\admin$ /user:&lt;admin username</span></b><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&gt; &nbsp; </span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Example: </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;"><br />
</span><b><span style="font-family: &quot;Courier New&quot;;">C:\&gt;net use<br />
\\192.168.1.1\admin$ /user:paja</span></b><b><span style="font-family: Verdana;"><br />
</span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Use regedt32 to modify the registry entry to allow telnet<br />
without NTLM. </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 12pt;"><b><span style="font-size: 10pt; font-family: Verdana;">Start-&gt;Run-&gt;regedt32<br />
</span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">connect to the remote machine: </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 12pt;"><b><span style="font-size: 10pt; font-family: Verdana;">Registry-&gt;Select<br />
Computer </span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">in the &#8220;Computer&#8221; field, enter </span><span style="font-family: Verdana;">&#8220;</span><b><span style="font-family: &quot;Courier New&quot;;">\\&lt;ip<br />
address</span></b><span style="font-family: Verdana;">&#8221; </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 12pt;"><span style="font-size: 10pt; font-family: Verdana;">Set the following key<br />
to 0: </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><b><span style="font-family: &quot;Courier New&quot;;">\HKEY_LOCAL_MACHINE<br />
on &lt;ipaddress&gt;\SOFTWARE\Microsoft \TelnetServer\1.0\NTLM </span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Use netsvc.exe to start telnet service (tlntsvr):</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><b><span style="font-family: &quot;Courier New&quot;;">c:\&gt;netsvc<br />
tlntsvr \\&lt;ip address&gt; /start </span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">From the telnet session, use the &#8220;logoff&#8221;<br />
command with session IDs of &#8220;1&#8243; and &#8220;2&#8243; to end the<br />
disconnected but active sessions: </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;"><br />
</span><b><span style="font-family: &quot;Courier New&quot;;">C:\&gt;logoff 1 <br />
C:\&gt;logoff 2 <br />
C:\&gt;exit </span></b></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">(Be patient. Logoff takes some time.)</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">Use netsvc.exe to stop the telnet service if you want: </span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><span style="font-size: 10pt; font-family: Verdana;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt;"><b><span style="font-family: &quot;Courier New&quot;; color: black;">C:\netsvc tlntsvr \\&lt;ip address&gt; /stop</span></b></p>
<p>notes from <a href="http://www.milovanovic.com/tsproblem.htm" target="_blank">Vladimir Milovanovic&#8217;s blog</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/12/13/the-terminal-server-has-exceeded-the-maximum-number-of-allowed-connections-the-system-cannot-log-you-on-1b8e-please-try-again-or-consult-your-system-administrator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IIS Settings Replication on a web farm</title>
		<link>http://mahpour.com/blog/2007/12/06/iis-settings-replication-on-a-web-farm/</link>
		<comments>http://mahpour.com/blog/2007/12/06/iis-settings-replication-on-a-web-farm/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 15:15:28 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[HTML/CSS Tips]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2007/12/06/iis-settings-replication-on-a-web-farm/</guid>
		<description><![CDATA[I was looking for a simple solution to synchronize the IIS settings across a webfarm that I found an interesting post on Scott&#8217;s webblog.

Included Files
With the theory behind us, let&#8217;s take a look at the files included in the download file. Note that I did not try to pretty it up or put a lot [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a simple solution to synchronize the IIS settings across a webfarm that I found an interesting post on <a href="http://weblogs.asp.net/owscott/archive/2006/06/07/IISCnfg.vbs---IIS-Settings-Replication.aspx" target="_blank">Scott&#8217;s webblog</a>.
</p>
<p><strong><font face="Arial" size="4">Included Files</font></strong></p>
<p><font face="Arial">With the theory behind us, let&#8217;s take a look at the files included in the download file. Note that I did not try to pretty it up or put a lot of error checking in it. It&#8217;s simple and easy to understand, but that also means that you may need to do some digging into the files to make any changes or to troubleshoot any issues that I didn&#8217;t handle in a friendly way.</font></p>
<p><strong>
<p><font face="Arial">[The first two files are the ones that you will use to do a Metabase Merge or Push.]</font></p>
<p></strong><strong><em>
<p><font face="Arial">MetabasePush.bat</font></p>
<p></em></strong>
<p><font face="Arial">Usage: MetabasePush {ServerIP} [SMTP FQDN]</font></p>
<p><font face="Arial">You can call this from a batch file that can live somewhere else, like on the desktop of your primary web server. It will do a metabase push from the current server (localhost) to the target server specified by the ServerIP. </font></p>
<p><font face="Arial">You can optionally add the SMTP FQDN and it will update that on the target server. We use that at ORCS Web because each server node has a different SMTP FQDN.</font></p>
<p><strong><em>
<p><font face="Arial">MetabaseMerge.bat</font></p>
<p></em></strong>
<p><font face="Arial">Usage: MetabaseMerge {ServerIP} [SMTP FQDN]</font></p>
<p><font face="Arial">This operates the same as MetabasePush except that it does a Merge instead. The ServerIP is required and the SMTP </font><font face="Arial">FQDN is optional. Don&#8217;t forget the differences mentioned above between a Push and Merge. </font><font face="Arial">This file calls RemoveAdminACLLine.vbs so that the target server retains its own security settings.</font></p>
<p><strong>
<p><font face="Arial">[The following files are helper files and don&#8217;t need to be run directly.]</font></p>
<p></strong><strong><em>
<p><font face="Arial">IIsCnfg2.vbs</font></p>
<p></em></strong>
<p><font face="Arial">This is a copy (confirmed up to date May 2006) of IIsCnfg.vbs but with two minor modifications to make the target username and password optional.</font></p>
<p><strong><em>
<p><font face="Arial">Metaacl.vbs</font></p>
<p></em></strong>
<p><font face="Arial">This is an untouched Microsoft script to view and update the metabase ACLs permissions.</font></p>
<p><strong><em>
<p><font face="Arial">RemoveAdminACLline.vbs</font></p>
<p></em></strong>
<p><font face="Arial">This is used by MetabaseMerge.bat to remove the ACL lines so that the permissions on the target server are left untouched during a Merge.</font></p>
<p><strong><em>
<p><font face="Arial">ChangeSMTP-FQDN.vbs</font></p>
<p></em></strong>
<p><font face="Arial">This will change the fully qualified domain name of the SMTP server on the target server that you specify. It is used when there are different SMTP DNS names on each server.</font></p>
<p><a href='http://mahpour.com/blog/wp-content/uploads/2007/12/clusterutils.zip' title='Scott Forsyth’s IIS Clustering Utilities'>Scott Forsyth’s IIS Clustering Utilities</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/12/06/iis-settings-replication-on-a-web-farm/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating a custom MachineKey in ASP.NET</title>
		<link>http://mahpour.com/blog/2007/12/06/creating-a-custom-machinekey-in-aspnet/</link>
		<comments>http://mahpour.com/blog/2007/12/06/creating-a-custom-machinekey-in-aspnet/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 15:01:31 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2007/12/06/creating-a-custom-machinekey-in-aspnet/</guid>
		<description><![CDATA[There are many times when it is worthwhile to create a custom machineKey for your web.config file.  This is worthwhile on a webfarm but also worthwhile on a stand-alone server so that your machineKey remains the same after an iisreset or application pool recycle. 

Try this online tool to generate the machinekey and enjoy!
]]></description>
			<content:encoded><![CDATA[<p>There are many times when it is worthwhile to create a custom machineKey for your web.config file.  This is worthwhile on a webfarm but also worthwhile on a stand-alone server so that your machineKey remains the same after an iisreset or application pool recycle. </p>
<p>
Try <a target="_blank" href="http://www.orcsweb.com/articles/aspnetmachinekey.aspx">this</a> online tool to generate the machinekey and enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/12/06/creating-a-custom-machinekey-in-aspnet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Cross Domain Ajax Calls</title>
		<link>http://mahpour.com/blog/2007/08/29/cross-domain-ajax-calls-2/</link>
		<comments>http://mahpour.com/blog/2007/08/29/cross-domain-ajax-calls-2/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 15:43:30 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[HTML/CSS Tips]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2007/08/29/cross-domain-ajax-calls-2/</guid>
		<description><![CDATA[Here are a few of the most popular ways to do cross domain calls via JavaScript: proxies, JSON, and Flash.
Cross domain proxy
This is one of the most common approaches. Your script calls your server, your server makes the call to the remote server and then returns the result back to the client. There are some [...]]]></description>
			<content:encoded><![CDATA[<p>Here are a few of the most popular ways to do cross domain calls via JavaScript: proxies, JSON, and Flash.</p>
<h2>Cross domain proxy</h2>
<p>This is one of the most common approaches. Your script calls your server, your server makes the call to the remote server and then returns the result back to the client. There are some definite advantages to this approach: you have more control over the entire lifecycle. You can parse the data from the remote server, do with it what you will before sending it back to the client. If anything fails along the way, you can handle it in your own way. And lastly, you can log all remote calls. WIth that you can track success, failure and popularity.</p>
<h2>Cross domain JSON</h2>
<p>For this to work, the remote server needs to be set up to handle this. It needs to accept an additional parameter: a callback function. Then, to make the remote request, you insert a new script tag into your page with which will allow you to specify a remote URL. The reponse back will load a JSON object as a parameter of the callback function you specified in the request. Yahoo, for example, has implemented this feature in their web services API&#8217;s. This is great because you can implement web service calls without ever needing a scripting language on your server. Check out Jason Levitt&#8217;s article, <a href="http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html">JSON and the Dynamic Script Tag</a>, on XML.com for more information.</p>
<h2>Cross domain using Flash</h2>
<p>Flash, by default, is much like Ajax in that you cannot request data from a remote server. However, you can enable this capability by placing a special XML file on the remote server to accept requests from other domains. With JavaScript&#8217;s capability to interact with Flash, we can <a href="http://blog.monstuff.com/archives/000280.html">use Flash as a bridge for sending cross-domain requests</a>. (XML.com has a nice <a href="http://www.xml.com/pub/a/2006/06/28/flashxmlhttprequest-proxy-to-the-rescue.html">write-up of this technique</a>.) There are still some limitations to this technique, most of which seems to be limited to older versions of Flash. There&#8217;s also the issue with users having Flash installed and enabled.</p>
<h2>Sub-domains are still cross domains</h2>
<p>One point to note and it&#8217;s fairly subtle. Plenty of us have our sites running at www.example.com and at example.com. They both point to the very same place. To us, we see them as the same thing. But to an Ajax call, it&#8217;s considered cross domain. Therefore, if you have to make an Ajax call to the same server, don&#8217;t code the domain as part of the request; just use the path.</p>
<h2>The Future</h2>
<p>Some have already begun looking into establishing standards that could be implemented into future browsers, such as <a href="http://json.org/JSONRequest.html">JSONRequest</a> and <a href="http://chrisholland.blogspot.com/2005/03/contextagnosticxmlhttprequest-informal.html">ContextAgnosticXMLHttpRequest</a>. JSONRequest seems the most promising but that could be because I prefer JSON over XML and see it as really gaining traction over the next couple years.</p>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/08/29/cross-domain-ajax-calls-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Cross Domain Ajax Calls</title>
		<link>http://mahpour.com/blog/2007/08/29/cross-domain-ajax-calls/</link>
		<comments>http://mahpour.com/blog/2007/08/29/cross-domain-ajax-calls/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 15:42:27 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[HTML/CSS Tips]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2007/08/29/cross-domain-ajax-calls/</guid>
		<description><![CDATA[
When Microsoft added the ActiveX XMLHTTP object to Internet Explorer&#8217;s implementation of JavaScript, the company planted the seed for the revolution in Web applications known as Asynchronous JavaScript and XML, or AJAX. Today, Firefox, Safari, Opera, and other browsers all support what is now known as XMLHttpRequest, making possible sites such as colr.org, backpackit.com, and [...]]]></description>
			<content:encoded><![CDATA[<p><font size="-1" face="Verdana, Arial, Helvetica"></p>
<p>When Microsoft added the ActiveX XMLHTTP object to Internet Explorer&#8217;s implementation of JavaScript, the company planted the seed for the revolution in Web applications known as Asynchronous JavaScript and XML, or AJAX. Today, Firefox, Safari, Opera, and other browsers all support what is now known as XMLHttpRequest, making possible sites such as <a target="new" href="http://colr.org/">colr.org</a>, <a target="new" href="http://backpackit.com/">backpackit.com</a>, and <a target="new" href="http://maps.google.com/">maps.google.com</a>. These and other sites feature applications that act and feel like other desktop applications&mdash;even though they&#8217;re running in a browser.</p>
<p>In AJAX, the JavaScript on the page sends requests to a Web server for data while the user&#8217;s viewing and interacting with the page (hence the &quot;asynchronous&quot; part of AJAX). Those requests are HTTP requests just like the one the browser used to retrieve the page in the first place, as well as any images, stylesheets, and so forth. As such, the XMLHttpRequest object can be used to retrieve any kind of data, not just XML. For example, JavaScript can use XMLHttpRequest to retrieve a plain text file from a Web server and display its contents within a form.</p>
<p>The XMLHttpRequest object analyzes the MIME type of the data coming back from the Web server by looking at the Content-type header that precedes the data. If it&#8217;s <tt>text/plain</tt> for example, you can access the text by examining the XMLHttpRequest object&#8217;s <tt>responseText</tt> property. But, if it&#8217;s <tt>text/xml</tt>, the XMLHttpRequest object takes an extra step: It runs an XML parser on the returned document and builds a Document Object Model (DOM) tree in memory representing the document, and makes that available in the <tt>responseXML</tt> property. You then can use JavaScript&#8217;s standard DOM methods to navigate the tree and retrieve elements, attributes, and other text occurring in the tree.</p>
<p>XML is <em>the</em> standard way to interchange data, but it&#8217;s often not the <em>best</em> way. Although XML can add structure and metadata to data, it does so in an overly verbose way. XML also has a fairly complex syntax, requiring a non-trivial parser to attack it. In JavaScript, XML must be parsed into a DOM tree to be used. And, once you&#8217;ve constructed the DOM tree, you still have to pilot through it to create corresponding JavaScript objects or otherwise use the XML data in your client-side Web application.</p>
<p>Fortunately, there&#8217;s a better way.</p>
<p><font size="-1" face="Verdana, Arial, Helvetica"></p>
<h3>Welcome to JSON</h3>
<p>The JavaScript Object Notation, or JSON, is a lightweight syntax for representing data. JSON&#8217;s elegance comes from the fact that it&#8217;s a <em>subset</em> of the JavaScript language itself. You&#8217;ll see why that&#8217;s important later. First, compare the raw syntax of JSON against XML.</p>
<p>Both XML and JSON use structured approaches to mark up data. For example, an address book application might provide a Web service that yields address cards in this XML format:</p>
<pre>&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;card&gt;   &lt;fullname&gt;Sean Kelly&lt;/fullname&gt;   &lt;org&gt;SK Consulting&lt;/org&gt;   &lt;emailaddrs&gt;      &lt;address type=&#8217;work&#8217;&gt;kelly@seankelly.biz&lt;/address&gt;      &lt;address type=&#8217;home&#8217; pref=&#8217;1&#8242;&gt;kelly@seankelly.tv&lt;/address&gt;   &lt;/emailaddrs&gt;   &lt;telephones&gt;      &lt;tel type=&#8217;work&#8217; pref=&#8217;1&#8242;&gt;+1 214 555 1212&lt;/tel&gt;      &lt;tel type=&#8217;fax&#8217;&gt;+1 214 555 1213&lt;/tel&gt;      &lt;tel type=&#8217;mobile&#8217;&gt;+1 214 555 1214&lt;/tel&gt;   &lt;/telephones&gt;   &lt;addresses&gt;      &lt;address type=&#8217;work&#8217; format=&#8217;us&#8217;&gt;1234 Main St         Springfield, TX 78080-1216&lt;/address&gt;      &lt;address type=&#8217;home&#8217; format=&#8217;us&#8217;&gt;5678 Main St         Springfield, TX 78080-1316&lt;/address&gt;   &lt;/addresses&gt;   &lt;urls&gt;      &lt;address type=&#8217;work&#8217;&gt;http://seankelly.biz/&lt;/address&gt;      &lt;address type=&#8217;home&#8217;&gt;http://seankelly.tv/&lt;/address&gt;   &lt;/urls&gt;&lt;/card&gt;</pre>
<p>With JSON, it looks like this:</p>
<pre>{   &quot;fullname&quot;: &quot;Sean Kelly&quot;,   &quot;org&quot;: &quot;SK Consulting&quot;,   &quot;emailaddrs&quot;: [      {&quot;type&quot;: &quot;work&quot;, &quot;value&quot;: &quot;kelly@seankelly.biz&quot;},      {&quot;type&quot;: &quot;home&quot;, &quot;pref&quot;: 1, &quot;value&quot;: &quot;kelly@seankelly.tv&quot;}   ],    &quot;telephones&quot;: [      {&quot;type&quot;: &quot;work&quot;, &quot;pref&quot;: 1, &quot;value&quot;: &quot;+1 214 555 1212&quot;},      {&quot;type&quot;: &quot;fax&quot;, &quot;value&quot;: &quot;+1 214 555 1213&quot;},      {&quot;type&quot;: &quot;mobile&quot;, &quot;value&quot;: &quot;+1 214 555 1214&quot;}   ],   &quot;addresses&quot;: [      {&quot;type&quot;: &quot;work&quot;, &quot;format&quot;: &quot;us&quot;,       &quot;value&quot;: &quot;1234 Main StnSpringfield, TX 78080-1216&quot;},      {&quot;type&quot;: &quot;home&quot;, &quot;format&quot;: &quot;us&quot;,       &quot;value&quot;: &quot;5678 Main StnSpringfield, TX 78080-1316&quot;}   ],    &quot;urls&quot;: [      {&quot;type&quot;: &quot;work&quot;, &quot;value&quot;: &quot;http://seankelly.biz/&quot;},      {&quot;type&quot;: &quot;home&quot;, &quot;value&quot;: &quot;http://seankelly.tv/&quot;}   ]}</pre>
<p>As you can see, JSON has structure with nesting of data elements, just as XML does. JSON too is text-based, as XML is. Both use Unicode. JSON is just as readable by humans as XML is. Subjectively, JSON is clearer and has less redundancy. The <a target="new" href="http://json.org/">JSON Web site</a> describes the syntax of JSON rigorously, and yet does so briefly. It really is a simple little language! XML is certainly appropriate for marking up documents, but JSON is ideal for <em>data interchange</em>. Each instance of a JSON document describes <em>one object</em> with nested objects, arrays, strings, numbers, boolean values, or null values.</p>
<p>In these address card examples, the JSON version is lighter weight, taking 682 bytes of space, whereas the XML version requires 744. That&#8217;s not a spectacular savings, of course. The real benefits come in the parsing.</p>
<p><!------- begin page 2 -------></p>
<h3>XML Versus JSON: the Smackdown!</h3>
<p>By using the XMLHttpRequest object, you can retrieve both XML and JSON files from within your AJAX-based application. Typically, your interaction will go something like this:</p>
<pre>var req = new XMLHttpRequest();req.open(&quot;GET&quot;, &quot;http://localhost/addr?cardID=32&quot;, /*async*/true);req.onreadystatechange = myHandler;req.send(/*no params*/null);</pre>
<p>As the Web server replies, the handler function you passed in (<tt>myHandler</tt> in this example) is called repeatedly, affording you an opportunity to abort the transaction early, update a progress bar, and so forth. Frequently, you only take action when the Web request is complete; at that time, you use the returned data.</p>
<p>To handle the XML version of your address card, the code for <tt>myHandler</tt> might look something like this:</p>
<pre>function myHandler() {   if (req.readyState == 4 /*complete*/) {       // Update address field in a form with first street address       var addrField   = document.getElementById(&#8217;addr&#8217;);       var root        = req.responseXML;       var addrsElem   = root.getElementsByTagName(&#8217;addresses&#8217;)[0];       var firstAddr   = addrsElem.getElementsByTagName(&#8217;address&#8217;)[0];       var addrText    = fistAddr.firstChild;       var addrValue   = addrText.nodeValue;       addrField.value = addrValue;   }}</pre>
<p>Notice that you didn&#8217;t have to parse the XML document; the XMLHttpRequest object did that automatically and made the parsed DOM tree available in the <tt>responseXML</tt> property. By using that property, you call the <tt>getElementsByTagName</tt> method to find the <tt>addresses</tt> part of the document, and you use the first one (of only one) found. Then, you call <tt>getElementsByTagName</tt> again this time on that <tt>addresses</tt> element to find the first <tt>address</tt> element, and again use the first one found. Then, you get the first DOM child of that element, which is a text node, and get the node&#8217;s value, which is the street address you want. Finally, you can display it in the form field.</p>
<p>That&#8217;s a lot of work! Now, let&#8217;s try it with JSON:</p>
<pre>function myHandler() {   if (req.readyState == 4 /*complete*/) {       var addrField = document.getElementById(&#8217;addr&#8217;);       var card = eval(&#8217;(&#8217; + req.responseText + &#8216;)&#8217;);       addrField.value = card.addresses[0].value;   }}</pre>
<p>The first thing you need to do is manually parse the JSON response. However, because JSON is a subset of JavaScript, you can use JavaScript&#8217;s own compiler to do just that by calling <tt>eval</tt>. Parsing JSON is a one-liner! Moreover, navigating an object synthesized from JSON is identical to navigating any JavaScript object. It&#8217;s far easier than navigating through the DOM tree. For example:</p>
<ul>
<li><tt>card.addresses[0].value</tt> is the first street address, &quot;1234 Main Stb &amp;&quot;</li>
<li><tt>card.addresses[0].type</tt> is the type of the address, &quot;work&quot;</li>
<li><tt>card.addresses[1]</tt> is an object which is the home address</li>
<li><tt>card.fullname</tt> is the name on the card, &quot;Sean Kelly&quot;</li>
</ul>
<p>If you&#8217;re watching closely, you might&#8217;ve noticed that the XML version at least states up front what object is contained in the document with the root document element, <tt>card</tt>. This is absent in the JSON version. Why? Presumably, if you&#8217;re developing JavaScript that accesses a Web service, you already know what you&#8217;re going to get back. However, you can include such a nicety in JSON:</p>
<pre>{&quot;card&quot;: {&quot;fullname&quot;: ...}}</pre>
<p>By using this technique, your JSON files always start with an object with a single named property that identifies the &quot;kind&quot; of the object.</p>
<p>
</p>
<p></font></p>
<p></font></p>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/08/29/cross-domain-ajax-calls/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Implementing Paging and Dynamic Sorting on SQL 2005 databases</title>
		<link>http://mahpour.com/blog/2007/05/08/implementing-paging-and-dynamic-sorting-on-sql-2005-databases/</link>
		<comments>http://mahpour.com/blog/2007/05/08/implementing-paging-and-dynamic-sorting-on-sql-2005-databases/#comments</comments>
		<pubDate>Tue, 08 May 2007 21:22:56 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2007/05/08/implementing-paging-and-dynamic-sorting-on-sql-2005-databases/</guid>
		<description><![CDATA[ROW_NUMBER() is a new function in SQL 2005 that returns the sequential number of a row within a partition of a result set,  starting at 1 for the first row in each partition.

DECLARE @START int;
DECLARE @END int;
DECLARE @Sort nvarchar(100);
SET @Start=10;
SET @END=20;
SET @Sort=&#8217;LastName&#8217;;
SELECT *&#160; FROM (SELECT ROW_NUMBER() over (
&#160;&#160;&#160; &#160;&#160;&#160; ORDER BY CASE
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>ROW_NUMBER() is a new function in SQL 2005 that returns the sequential number of a row within a partition of a result set,  starting at 1 for the first row in each partition.</p>
<p><font face="Courier New"></font></p>
<div class="Code"><font face="Courier New">DECLARE @START int;<br />
DECLARE @END int;<br />
DECLARE @Sort nvarchar(100);<br />
SET @Start=10;<br />
SET @END=20;<br />
SET @Sort=&#8217;LastName&#8217;;<br />
SELECT *&nbsp; FROM (SELECT ROW_NUMBER() over (<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ORDER BY CASE<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHEN @Sort=&#8217;FirstName&#8217; THEN FirstName<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHEN @Sort=&#8217;LastName&#8217; THEN LastName<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ELSE FirstName<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; END) as R ,* From Students) as tbl<br />
WHERE R BETWEEN @Start AND @End</font></div>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/05/08/implementing-paging-and-dynamic-sorting-on-sql-2005-databases/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to sort the SQL results dynamically (dynamic ORDER BY)</title>
		<link>http://mahpour.com/blog/2007/05/08/how-to-sort-the-sql-results-dynamically-dynamic-order-by/</link>
		<comments>http://mahpour.com/blog/2007/05/08/how-to-sort-the-sql-results-dynamically-dynamic-order-by/#comments</comments>
		<pubDate>Tue, 08 May 2007 21:11:59 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2007/05/08/how-to-sort-the-sql-results-dynamically-dynamic-order-by/</guid>
		<description><![CDATA[The solution is using CASE statement in your select query .
Here&#8217;s a sample:
&#160;
 DECLARE @sortColumn VARCHAR(255)
SELECT @sortColumn = &#8216;title&#8217;
SELECT * FROM asset
ORDER BY
CASE 
WHEN @sortColumn = &#8216;title&#8217; THEN title
WHEN @sortColumn = &#8217;start_date&#8217; THEN start_date
WHEN @sortColumn = &#8216;asset_id&#8217; THEN asset_id
ELSE title
END
]]></description>
			<content:encoded><![CDATA[<p>The solution is using CASE statement in your select query .</p>
<p>Here&#8217;s a sample:<br />
&nbsp;<br />
<font face="Courier New"> DECLARE @sortColumn VARCHAR(255)<br />
SELECT @sortColumn = &#8216;title&#8217;</p>
<p>SELECT * FROM asset<br />
ORDER BY<br />
CASE <br />
WHEN @sortColumn = &#8216;title&#8217; THEN title<br />
WHEN @sortColumn = &#8217;start_date&#8217; THEN start_date<br />
WHEN @sortColumn = &#8216;asset_id&#8217; THEN asset_id<br />
ELSE title<br />
END</font></p>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/05/08/how-to-sort-the-sql-results-dynamically-dynamic-order-by/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Setup a source versioning software on your windows server for FREE!</title>
		<link>http://mahpour.com/blog/2007/04/24/setup-a-source-versioning-software-on-your-windows-server-for-free/</link>
		<comments>http://mahpour.com/blog/2007/04/24/setup-a-source-versioning-software-on-your-windows-server-for-free/#comments</comments>
		<pubDate>Tue, 24 Apr 2007 19:56:37 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

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

		<guid isPermaLink="false">http://mahpour.com/blog/2007/04/24/setup-a-source-versioning-software-on-your-windows-server-for-free/</guid>
		<description><![CDATA[Subversion sounds pretty cool. It&#8217;s a mature, powerful revision-control system that acts a lot like CVS, adds support for atomic commits and real renames, just won the Jolt award, and is free. What more can you ask for?
I&#8217;ve been intending to install Subversion for quite a while, but I kept putting it off, because it [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion sounds pretty cool. It&#8217;s a mature, powerful revision-control system that acts a lot like CVS, adds support for atomic commits and real renames, just <a href="http://www.sdmagazine.com/documents/s=9785/sdm0506b/0506b4.html">won the Jolt award</a>, and is free. What more can you ask for?</p>
<p>I&#8217;ve been intending to install Subversion for quite a while, but I kept putting it off, because it looked like a daunting task. But when I actually decided to go do it, it took me all of an hour and a half to get it installed and working. If somebody had just written down what I needed to do to set up Subversion on Windows, with a real server running as a real Windows service, then it probably would&#8217;ve only taken me ten minutes, and I would&#8217;ve done it weeks ago.</p>
<p>Here, then, is the <strong>Mere-Moments Guide to installing a Subversion server on Windows</strong>. (It may look a bit intimidating, but really, it&#8217;s not.)</p>
<p>Some quick notes on the Guide:</p>
<ul>
<li>These instructions assume you&#8217;re using Windows 2000 or XP. (You&#8217;d better be; the Subversion server won&#8217;t run on Win9x.)  </li>
<li>If you want to know more about Subversion than just how to install it, check out the free <a href="http://svnbook.red-bean.com/">O&#8217;Reilly Subversion book online</a> and the not-free <a href="http://www.pragmaticprogrammer.com/titles/svn/">Pragmatic Version Control using Subversion</a>.  </li>
<li>For Subversion to do you much good, you&#8217;ll have to add a new &quot;project&quot; (essentially a directory) to your repository, to put files in. In these instructions, I&#8217;m assuming that your new project will be called <font face="Courier New">monkey</font> (because mine was).  </li>
<li>Feel free to skip steps and to play around; you&#8217;ll learn more that way, because things won&#8217;t work right and you&#8217;ll have to figure out why.</li>
</ul>
<p>And now, on to the Guide.</p>
<ol type="I">
<li><strong>Download everything</strong>
<ol>
<li>Go to <a href="http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91">http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91</a>&nbsp;and download the most recent <strong>svn-<em>x.y.z</em>-setup.exe</strong>. At the time of this writing, the latest version was <a href="http://subversion.tigris.org/files/documents/15/23230/svn-1.2.0-setup.exe">svn-1.2.0-setup.exe</a>.  </li>
<li>Go to <a href="http://dark.clansoft.dk/%7Embn/svnservice/">http://dark.clansoft.dk/~mbn/svnservice/</a>&nbsp;and download <strong>SVNService.zip</strong>.  </li>
<li>Go to <a href="http://tortoisesvn.tigris.org/download.html">http://tortoisesvn.tigris.org/download.html</a>&nbsp;and download the most recent installer. At the time of this writing, the latest version was <a href="http://tortoisesvn.tigris.org/files/documents/406/22868/TortoiseSVN-1.1.7-UNICODE_svn-1.1.4.msi">TortoiseSVN-1.1.7-UNICODE_svn-1.1.4.msi</a>. (It doesn&#8217;t have to be the exact same version as the svn installer you got in step 1. See the <a href="http://tortoisesvn.tigris.org/compatibility.html">compatibility chart</a>.)</li>
</ol>
</li>
<li><strong>Install the server and the command-line client</strong>
<ol>
<li>Run svn-x.y.z-setup.exe and let it install stuff.  </li>
<li>Go to Control Panel &gt; System, go to the Advanced tab, and click the &quot;Environment Variables&quot; button at the bottom. Click the &quot;New&quot; button (either one, but if you&#8217;re undecided, use the one under &quot;System variables&quot;), set &quot;variable name&quot; to <font face="Courier New">SVN_EDITOR</font>, and &quot;variable value&quot; to the path and filename of a text editor of your choice (e.g., <font face="Courier New">C:\Windows\Notepad.exe</font>). OK all the way out.</li>
</ol>
</li>
<li><strong>Create a repository and configure access</strong>
<ol>
<li>Create a new directory somewhere out of the way; this is where your repository will live, but you&#8217;ll almost never actually open the files directly. I made a directory called <font face="Courier New">svn_repos</font> directly under my C:\Documents and Settings, just so it&#8217;d be out of the way.  </li>
<li>Open a command prompt and type: <font face="Courier New">svnadmin create &quot;C:\Documents and Settings\svn_repos&quot;</font>  </li>
<li>In Windows Explorer, browse to the C:\Documents and Settings\svn_repos\conf directory (which svnadmin just created for you), and edit a couple of config files:
<ol type="a">
<li>Open the svnserve.conf file in a text editor, and uncomment the <font face="Courier New">[general]</font>, <font face="Courier New">anon-access = read</font>, <font face="Courier New">auth-access = write</font>, and <font face="Courier New">password-db = passwd</font> lines. Save.  </li>
<li>Open the passwd file in a text editor, uncomment the [users] line, and add the username and password you want to use when connecting to your subversion server. Save.</li>
</ol>
</li>
</ol>
</li>
<li><strong>Start the server manually, and create a project</strong>
<ol>
<li>In your command window, type: <font face="Courier New">svnserve &#8211;daemon &#8211;root &quot;C:\Documents and Settings\svn_repos&quot;</font>  </li>
<li>Open a second command window, and type <font face="Courier New">svn mkdir svn://localhost/monkey</font>  </li>
<li>You&#8217;ll see the text editor you specified in step II.2, with some text already in it. Type a comment, like &quot;Created the monkey project&quot;, at the beginning of the file (before the line starting with &quot;&#8211;&quot;). Save the file and close the editor. </li>
<li>If your Subversion login is the same as your Windows login, then type your password (the one you put in the passwd file) at the prompt, and hit Enter. If your Subversion login is different from your Windows login, then just hit ENTER at the password prompt, and Subversion will then ask for both your login and your password. </li>
<li>Subversion should tell you that it &quot;Committed revision 1.&quot; Congratulations! You just checked a change into Subversion. Throw yourself a party. (Yes, creating a directory is a revisioned change &mdash; you can go back and get the repository as of a time before that directory existed. This is novel stuff for folks like me who still use VSS at work.) </li>
<li>It&#8217;s conventional to have /trunk, /branches, and /tags subdirectories for each project (your code goes into trunk, and the others are where you put, well, branches and tags). Go ahead and type <font face="Courier New">svn mkdir svn://localhost/monkey/trunk</font> (and notice that, after you enter a checkin comment, it doesn&#8217;t prompt you for your password again &mdash; it&#8217;s smart like that).</li>
</ol>
</li>
<li><strong>Start the server for real</strong>
<ol>
<li>Go back to the command window that&#8217;s running svnserve. Hit Ctrl+C to stop it.  </li>
<li>Open the SVNService.zip that you downloaded earlier. Extract SVNService.exe into your Subversion bin directory (Program Files\Subversion\bin). Yes, it&#8217;s important that you put it in this directory; it has to be in the same place as svnserve.exe from the Subversion distribution. </li>
<li>In a command prompt, type <font face="Courier New">svnservice -install &#8211;daemon &#8211;root &quot;C:\Documents and Settings\svn_repos&quot;</font>  </li>
<li>Go to Control Panel &gt; Administrative Tools &gt; Services, double-click the SVNService service, and change its startup type from &quot;Manual&quot; to &quot;Automatic&quot;. Now Subversion will start every time you start Windows. </li>
<li>Start the SVNService service (by selecting it in the Services list, and clicking the &quot;play&quot; toolbar button).  </li>
<li>Go back to a command prompt, and type <font face="Courier New">svn ls svn://localhost/</font><br />
        This will list all the files in the root of the repository. If all is well and you&#8217;ve got a real Subversion server running now, you should see: <font face="Courier New">monkey/</font></li>
</ol>
</li>
<li><strong>Install TortoiseSVN<br />
    </strong>Sure, you can get by with a command-line client, but TortoiseSVN is cool &mdash; it integrates Subversion into Windows Explorer. You get little overlay icons showing the status of each file (in sync, needs to be checked in, not yet in the repository, etc.), and you can do pretty much everything you need by right-clicking on files and folders.</p>
<ol>
<li>Run the TortoiseSVN installer you got back in part I.  </li>
<li>Create a <font face="Courier New">monkey</font> directory somewhere on your hard drive. Right-click somewhere in that folder and select &quot;SVN Checkout&#8230;&quot; Type <font face="Courier New">svn://localhost/monkey/trunk/</font> for the repository URL and click OK.  </li>
<li>Create a file in that directory, any file. Right-click the file and select TortoiseSVN &gt; Add. Notice the little plus-sign icon that appears.<br />
        The file hasn&#8217;t actually been checked in yet &mdash; Subversion&#8217;s commits are both batched and atomic, so this new file, together with any other new files you added, any files you changed, any files you deleted, any files you renamed, any directories you added or deleted or renamed, will all show up on the server all at once, as a single revision and a single checkin, the next time you right-click and select &quot;SVN Commit&quot;.</li>
</ol>
</li>
<li><strong>Make it run on the network<br />
    </strong>Are you kidding? You&#8217;re already networked. Go to another computer on your LAN, install TortoiseSVN, and do an &quot;SVN Checkout&#8230;&quot;. When you specify the repository URL, use the same URL you did before, but replace &quot;localhost&quot; with the actual name of the computer that&#8217;s running the Subversion service (so in my case, the repository URL is svn://marsupial/monkey/trunk/ &mdash; nice little menagerie, there).</li>
</ol>
<p>And there ya go &mdash; Subversion up and running on Windows, in mere moments or less.</p>
<p>Corrections, questions, etc. on this document are, as always, welcome; just speak up in the comments. Now go forth and control your revisions.</p>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/04/24/setup-a-source-versioning-software-on-your-windows-server-for-free/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A quick glance at Microsoft Enterprise Library 2.0 - Logging Unhandled Exceptions</title>
		<link>http://mahpour.com/blog/2007/04/24/a-quick-glance-at-microsoft-enterprise-library-20-logging-unhandled-exceptions/</link>
		<comments>http://mahpour.com/blog/2007/04/24/a-quick-glance-at-microsoft-enterprise-library-20-logging-unhandled-exceptions/#comments</comments>
		<pubDate>Tue, 24 Apr 2007 14:27:20 +0000</pubDate>
		<dc:creator>mahpour</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://mahpour.com/blog/2007/04/24/a-quick-glance-at-microsoft-enterprise-library-20-logging-unhandled-exceptions/</guid>
		<description><![CDATA[Let&#8217;s use the Enterprise Library 2.0 Logging Application Block&#160;in an ASP.NET 2.0 Website using the most simplistic, yet very important case of logging unhandled exceptions. If you log nothing else in your ASP.NET websites, make sure you log unhandled exceptions so that you have some idea of the health of your application.&#160; Enterprise Library 2.0 [...]]]></description>
			<content:encoded><![CDATA[<p><font size="2" face="Verdana">Let&#8217;s use the <strong>Enterprise Library 2.0 Logging Application Block</strong>&nbsp;in an </font><a href="http://davidhayden.com/blog/dave/category/25.aspx?Show=All"><font size="2" face="Verdana">ASP.NET 2.0</font></a><font size="2" face="Verdana"> Website using the most simplistic, yet very important case of logging unhandled exceptions. If you log nothing else in your ASP.NET websites, make sure you log unhandled exceptions so that you have some idea of the health of your application.&nbsp; </font><a href="http://davidhayden.com/blog/dave/category/50.aspx"><font size="2" face="Verdana">Enterprise Library 2.0</font></a><font size="2" face="Verdana"> can email you the exception if you want, but I am going to keep things real simple and just have the exceptions logged to a file on the webserver.</font></p>
<p>&nbsp;</p>
<h2><font face="Verdana">Enterprise Library Configuration Tool</font></h2>
<p><font size="2" face="Verdana">Once I create my website in Visual Studio 2005, I immediately open up the </font><a href="http://davidhayden.com/blog/dave/archive/2006/01/23/2744.aspx"><font size="2" face="Verdana">Enterprise Library Configuration Tool</font></a><font size="2" face="Verdana"> and use it to open the existing <strong>web.config</strong> file.&nbsp; Using only the tool, I then add the logging application block configuration section to web.config, remove all the defaults, and replace them with a simple FlatFile&nbsp;</font><a href="http://davidhayden.com/blog/dave/archive/2006/02/14/2801.aspx"><font size="2" face="Verdana">TraceListener</font></a><font size="2" face="Verdana"> that catches all events as shown below:</font></p>
<p>&nbsp;</p>
<p align="center"><font size="2" face="Verdana"><img src="http://www.davidhayden.com/davidhayden/images/data/enterpriselibraryloggingapplicationblock.jpg" alt="" /></font></p>
<p>&nbsp;</p>
<p><font size="2" face="Verdana">The <strong>Logging Application Block</strong> has a <strong>Special Source</strong>, called <strong>All Events</strong>.&nbsp; Hooking a TraceListener to this event guarantees you will receive all events not being filtered.&nbsp; Since we have no filters, we get all events.&nbsp; These events get logged to the FlatFile TraceListener, which points to a log file at the root of my website, called <strong>trace.log</strong> ( default name ).</font></p>
<p>&nbsp;</p>
<h2><font face="Verdana">Catching and Logging Unhandled ASP.NET Exceptions</font></h2>
<p><font size="2" face="Verdana">To catch unhandled exceptions in </font><a href="http://davidhayden.com/blog/dave/category/25.aspx?Show=All"><font size="2" face="Verdana">ASP.NET 2.0</font></a><font size="2" face="Verdana">, I need to do a couple of things.</font></p>
<p><font size="2" face="Verdana">First, I need to reference <strong>Microsoft.Practices.EnterpriseLibrary.Logging</strong>&nbsp;in my website.&nbsp; When you reference this library, it will also pull over a couple of other assemblies, Common and ObjectBuilder, that it depends upon.</font></p>
<p><font size="2" face="Verdana">Second, I&nbsp;need to add a Global Application File ( <strong>Global.asax</strong> ) to the website and enter the following code into <strong>Application_Error</strong>:</font></p>
<p>&nbsp;</p>
<pre><span style="color: rgb(0, 0, 0);">&lt;%</span><span style="color: rgb(0, 0, 0);">@ Application Language</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">C#</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">&lt;%</span><span style="color: rgb(0, 0, 0);">@ Import Namespace</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">Microsoft.Practices.                       EnterpriseLibrary.Logging</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);">

</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">script runat</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">server</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">

    </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> Application_Error(</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);"> sender, EventArgs e)     {        Exception ex </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Server.GetLastError().GetBaseException();

        </span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);"> message </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> ex.Message </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">                         </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">\nSOURCE: </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> ex.Source </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">                        </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">\nFORM: </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> Request.Form.ToString() </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">                         </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">\nQUERYSTRING: </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">                            Request.QueryString.ToString() </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">                        </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">\nTARGETSITE: </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> ex.TargetSite </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">                        </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">\nSTACKTRACE: </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> ex.StackTrace;

        Logger.Write(message</span><span style="color: rgb(0, 0, 0);">);    }

</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">script</span><span style="color: rgb(0, 0, 0);">&gt;</span></pre>
<p>&nbsp;</p>
<p><font face="Verdana"><font size="2"><strong>Logger</strong> is the name of the facade&nbsp;in the <strong>Logging Application Block</strong> to log messages.&nbsp; I grab the unhandled exception and send it out to be logged.&nbsp; The application doesn&#8217;t know and doesn&#8217;t care where; it is oblivious as to the actual logging strategy.</font></font></p>
<p>&nbsp;</p>
<h2><font face="Verdana">Creating An Unhandled Exception</font></h2>
<p><font size="2" face="Verdana">Let&#8217;s open up <strong>Default.aspx.cs</strong> file and make it&nbsp;throw&nbsp;an exception:</font></p>
<p>&nbsp;</p>
<pre><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> partial </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> _Default : System.Web.UI.Page {    </span><span style="color: rgb(0, 0, 255);">protected</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> Page_Load(</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);"> sender, EventArgs e)    {        </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> error </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Int32.Parse(</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 128, 128);">bbbbb</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);">);    }}</span></pre>
<p>&nbsp;</p>
<p><font size="2" face="Verdana">The above with throw a <strong>System.FormatException</strong> error which will be logged in the <strong>trace.log</strong> file when running the application:</font></p>
<p>&nbsp;</p>
<p><font size="2" face="Verdana" color="#000080">Timestamp: 2/15/2006 9:23:30 PM<br />
Message: Input string was not in a correct format&#8230;&lt;Stack Trace&gt;</font></p>
<p>&nbsp;</p>
<h2><font face="Verdana">Conclusion</font></h2>
<p><font size="2" face="Verdana">In about 15 minutes, you can successfully log unhandled exceptions in your ASP.NET 2.0 websites using Enterprise Library 2.0 Logging Application Block.</font></p>
<p>&nbsp;</p>
<p><font size="2" face="Verdana">Source:&nbsp; <a href="http://www.davidhayden.com/">David Hayden</a> ( <a href="http://www.davidhayden.com/">.NET Developer</a> )</font></p>
]]></content:encoded>
			<wfw:commentRss>http://mahpour.com/blog/2007/04/24/a-quick-glance-at-microsoft-enterprise-library-20-logging-unhandled-exceptions/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
