<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Diary of a Ninja</title><link>http://www.diaryofaninja.com</link><description>A blog about life, code and beating level 99 to brag to your mates.</description><language>English</language><copyright>Doug Rathbone</copyright><pubDate>3/11/2010 3:01:25 AM</pubDate><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/DiaryOfANinja" /><feedburner:info uri="diaryofaninja" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Twitterify your strings using c# regex</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/3F_qr529Kqw/twitterify-your-strings-using-c-regex</link><description>&lt;p&gt;So you’ve set up a twitter feed on your site – sweet. Now all your peeps can see how excited you are about the new limited edition Witney Houston EP you’ve been listening to. But then you post a link – or a reply to a fellow &lt;a href="http://www.urbandictionary.com/define.php?term=twitterati"&gt;twitterati&lt;/a&gt; member and those handy auto links you’ve become so used to aren’t there. Bummer duuude – lets fix that.&lt;/p&gt;  &lt;h3&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="twitter-bird-logo" border="0" alt="twitter-bird-logo" align="right" src="http://www.diaryofaninja.com/asset/blogimages/twitter-bird-logo_0f6797a6-72cc-48f2-a946-52cfd6a1c886.jpg" width="240" height="240" /&gt; Live and die by the Regex&lt;/h3&gt;  &lt;p&gt;As usually is the way with these things, Regex is the dark knight swoops in the night to save the day (no, not batman) – this case is no different. A few simple regex matches and we’re done.&lt;/p&gt;  &lt;h4&gt;What we want to replace:&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;All links starting with &lt;strong&gt;http://&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;All links starting with &lt;strong&gt;www&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;All twitter username links ie. &lt;a href="http://twitter.com/dougrathbone" target="_blank"&gt;@dougrathbone&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;All twitter hash tag links ie. &lt;a href="http://twitter.com/search?q=ChuckNorris" target="_blank"&gt;#chucknorris&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Let take a look at the code&lt;/h3&gt;  &lt;p&gt;The method i have listed below takes a twitter status string and applies all these rules:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static &lt;/span&gt;&lt;span style="color: #2b91af"&gt;String &lt;/span&gt;AddWebAndTwitterLinks(&lt;span style="color: blue"&gt;string &lt;/span&gt;input)
{
    &lt;span style="color: blue"&gt;string &lt;/span&gt;strWebLinks = &lt;span style="color: #a31515"&gt;@&amp;quot;(^|[\n ])([\w]+?://[\w]+[^ \n\r\t&amp;lt; ]*)&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;string &lt;/span&gt;strWebLinksWWW = &lt;span style="color: #a31515"&gt;@&amp;quot;(^|[\n ])((www|ftp)\.[^ \t\n\r&amp;lt; ]*)&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;string &lt;/span&gt;strTwitterNames = &lt;span style="color: #a31515"&gt;@&amp;quot;@(\w+)&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;string &lt;/span&gt;strTwitterTags = &lt;span style="color: #a31515"&gt;@&amp;quot;#(\w+)&amp;quot;&lt;/span&gt;;
    input = &lt;span style="color: #2b91af"&gt;Regex&lt;/span&gt;.Replace(input, strWebLinks, 
        &lt;span style="color: #a31515"&gt;&amp;quot; &amp;lt;a href=\&amp;quot;$2\&amp;quot; target=\&amp;quot;_blank\&amp;quot;&amp;gt;$2&amp;lt;/a&amp;gt;&amp;quot;&lt;/span&gt;);
    input = &lt;span style="color: #2b91af"&gt;Regex&lt;/span&gt;.Replace(input, strWebLinksWWW, 
        &lt;span style="color: #a31515"&gt;&amp;quot; &amp;lt;a href=\&amp;quot;http://$2\&amp;quot; target=\&amp;quot;_blank\&amp;quot;&amp;gt;$2&amp;lt;/a&amp;gt;&amp;quot;&lt;/span&gt;);
    input = &lt;span style="color: #2b91af"&gt;Regex&lt;/span&gt;.Replace(input, strTwitterNames, 
        &lt;span style="color: #a31515"&gt;&amp;quot;&amp;lt;a href=\&amp;quot;http://www.twitter.com/$1\&amp;quot; target=\&amp;quot;_blank\&amp;quot;&amp;gt;@$1&amp;lt;/a&amp;gt;&amp;quot;&lt;/span&gt;);
    input = &lt;span style="color: #2b91af"&gt;Regex&lt;/span&gt;.Replace(input, strTwitterTags, 
        &lt;span style="color: #a31515"&gt;&amp;quot;&amp;lt;a href=\&amp;quot;http://search.twitter.com/search?q=$1\&amp;quot; target=\&amp;quot;_blank\&amp;quot;&amp;gt;#$1&amp;lt;/a&amp;gt;&amp;quot;&lt;/span&gt;);

    &lt;span style="color: blue"&gt;return &lt;/span&gt;input;
}&lt;/pre&gt;

&lt;p&gt;And there we have it! An example of this in use if the twitter feed on the right hand side of this &lt;strong&gt;very page!&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/3F_qr529Kqw" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/03/10/twitterify-your-strings-using-c-regex</feedburner:origLink></item><item><title>Exchange 2010: Fixing Active Synch issues for iPhones and Blackberries</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/DHnXYIO5QIM/exchange-2010-fixing-active-synch-issues-for-iphones-and-blackberries</link><description>&lt;p&gt;While recently setting up a new Exchange 2010 box is came across an issue where some users that had active synch enabled for their user account still couldn’t synch using their iPhones or Blackberries. &lt;/p&gt;  &lt;p&gt;It turns out that Exchange during its forest prep had gone through AD and turned off inherited permissions on certain user group members that are considered security risks (Exchange Admins, Domain Admins etc). Turning these back on is very easy, so lets get those Blackberry, iPhone and Win mobile devices back online! &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Open &lt;strong&gt;Active Directory Users and Computers&lt;/strong&gt; &amp;gt;&amp;gt; View &amp;gt;&amp;gt; and click Advanced Features &lt;/li&gt;    &lt;li&gt;Open the &lt;strong&gt;Properties&lt;/strong&gt; of the active directory user your having issues synching. &lt;/li&gt;    &lt;li&gt;Select the &lt;strong&gt;Security&lt;/strong&gt; tab and click &lt;strong&gt;Advanced&lt;/strong&gt;. &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="activesynch1[3]" border="0" alt="activesynch1[3]" src="http://www.diaryofaninja.com/asset/blogimages/activesynch1%5B3%5D_f418ed58-339e-4678-9109-5e3a24a2e3d0.png" width="252" height="300" /&gt; &lt;/p&gt;      &lt;p&gt;Active Directory Users and Computers&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;In the &lt;strong&gt;Permissions&lt;/strong&gt; tab make sure the “&lt;strong&gt;Include inheritable permissions from this object’s parent&lt;/strong&gt;” box is ticked&amp;#160; &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="activesynch2[3]" border="0" alt="activesynch2[3]" src="http://www.diaryofaninja.com/asset/blogimages/activesynch2%5B3%5D_bcec4e72-bd23-4fb7-bc1f-d446d58f045c.png" width="300" height="227" /&gt; &lt;/p&gt;      &lt;p&gt;Active Directory Users and Computers&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;Wait for Active Directory to replicate (this can take up to 30 mins) and try to sync the device again.&amp;#160; If the issue was caused by a permissions issue then this should make your day :) &lt;/li&gt; &lt;/ol&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/DHnXYIO5QIM" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/02/27/exchange-2010-fixing-active-synch-issues-for-iphones-and-blackberries</feedburner:origLink></item><item><title>Exchange 2010: Fix broken Out of office replies</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/-okzeVInpS8/exchange-2010-fix-broken-out-of-office-replies</link><description>&lt;p&gt;After my recent service roll-up for Exchange 2010 users who were homed on one of my servers where unable to set their out-of-office replies on. After some quick troubleshooting it would appear that the service roll-up had reset some of the permissions on some of my Exchange IIS virtual directories.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="oof1" border="0" alt="oof1" src="http://www.diaryofaninja.com/asset/blogimages/oof1_3.png" width="550" height="97" /&gt;&lt;/p&gt;  &lt;h3&gt;Finding the problem&lt;/h3&gt;  &lt;p&gt;When opening a mailbox homed on an Exchange 2007/2010 server, Outlook will use auto-discovery services provided by your Client Access server to configure its Out-of-Office settings. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1. Check if your outlook client is connected using RPC or RPC/HTTP&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To check how your client is connected to exchange, you can right-click the Outlook icon located in your system tray while holding CTRL, and select Connection Status. This should bring up the window below:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.diaryofaninja.com/asset/blogimages/image_2e1a5598-500e-4a65-b77d-381db6a5506b.png" width="546" height="330" /&gt; &lt;/p&gt;  &lt;p&gt;I'm connected here using TCP/IP, and not using HTTPs. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2. Check which URL your Outlook client is using to configure the Out of office replies!&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When you hold down CTRL and right-click on the Outlook icon in your system tray, you can select “Test E-mail AutoConfiguration”&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="oof2" border="0" alt="oof2" src="http://www.diaryofaninja.com/asset/blogimages/oof2_63b6edc3-39fa-42bd-9a48-62524961fbd5.png" width="257" height="204" /&gt; &lt;/p&gt;  &lt;p&gt;When you’ve selected this the window below will show. Enter the email address and password your testing with. As we are only checking native exchange accounts untick the “GuessSmart” checkboxes.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.diaryofaninja.com/asset/blogimages/image_ac804dd7-478c-410e-9d18-0524fe396685.png" width="546" height="96" /&gt; &lt;/p&gt;  &lt;p&gt;After clicking Test, you will get the URL used to configure OOF, as shown below.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.diaryofaninja.com/asset/blogimages/image_d81c52e8-0172-483e-9ee1-6a270e2b4c7d.png" width="551" height="359" /&gt; &lt;/p&gt;  &lt;p&gt;Now that you know the URL to the exchange web service for this user, you can try and contact it, by simply entering the URL in a browser window and see if you can get through.&lt;/p&gt;  &lt;p&gt;Fixing issues&lt;/p&gt;  &lt;p&gt;In my case i was originally getting 403 unauthorised errors. This meant that i had the authentication properties on the &lt;strong&gt;EWS&lt;/strong&gt; virtual folder of this client access server – a quick tweak to allow windows authentication and i was on my way. &lt;/p&gt;  &lt;p&gt;My new response when accessing this URL is shown below (this is what it should look like):&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.diaryofaninja.com/asset/blogimages/image_ccf95fab-223d-4204-8f0c-03bec1ae5a7d.png" width="560" height="231" /&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/-okzeVInpS8" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/02/27/exchange-2010-fix-broken-out-of-office-replies</feedburner:origLink></item><item><title>Stopping Windows from updating dynamic DNS</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/ghnitwZTpNM/stopping-windows-from-updating-dynamic-dns</link><description>&lt;p&gt;Under certain conditions there are times when you have a machine in your domain that you don’t want to update its DNS A records. These are usually edge cases however the need is still there. I needed to do this recently, so as they say on &lt;em&gt;Law and Order&lt;/em&gt; in a robotic Stephen Hawking voice - &lt;em&gt;“These are their stories”&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="dns_2" border="0" alt="dns_2" align="right" src="http://www.diaryofaninja.com/asset/blogimages/dns_2_36b60292-5a7c-484f-893c-6e598e165bef.jpg" width="240" height="200" /&gt; In my situation i had an issue with a server that was accessible internally and externally and was hosting an SSL website – with two different IPs, certificates, addresses and so on. This meant that i needed to have the machine accessible from an internal hostname address (this was not an option for me) as well as hosted on an external domain name. &lt;/p&gt;  &lt;p&gt;This in turn meant that i needed it to sit on two different IP’s and only one of these should show up in DNS as its home (“… No multi-homing for you! …”), and becoming overly frustrated at the hourly DNS update that put my both machines IPs in DNS i set out to overcome this issue.&lt;/p&gt;  &lt;h3&gt;Operating systems affected&lt;/h3&gt;  &lt;p&gt;By default, the TCP/IP stack in NT 5.0 onwards attempts to register it's Host (A) record with it's DNS server. &lt;/p&gt;  &lt;p&gt;Operating systems that this should be affective for:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Windows Server 2000&lt;/li&gt;    &lt;li&gt;Windows Server 2003&lt;/li&gt;    &lt;li&gt;Windows Server 2008&lt;/li&gt;    &lt;li&gt;Windows XP&lt;/li&gt;    &lt;li&gt;Windows Vista&lt;/li&gt;    &lt;li&gt;Windows 7&lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Steps to complete&lt;/h3&gt;  &lt;p&gt;To make a machine stop attempting to publish their DNS names/addresses to their DNS server perform the following:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Log on to the server/client machine as Administrator &lt;/li&gt;    &lt;li&gt;Start the registry editor (regedit.exe) &lt;/li&gt;    &lt;li&gt;Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters &lt;/li&gt;    &lt;li&gt;From the Edit menu select New - DWORD value &lt;/li&gt;    &lt;li&gt;Enter a name of DisableDynamicUpdate and press Enter &lt;/li&gt;    &lt;li&gt;Double click on the new value and set to 1. Click OK &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;If there are multiple adapters in the machine you may not want to disable for all so instead of setting HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DisableDynamicUpdate to 1, set as 0 and then move to the sub key Interfaces\&amp;lt;interface name&amp;gt; and create the DisableDynamicUpdate value there and set to 1.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/ghnitwZTpNM" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/02/23/stopping-windows-from-updating-dynamic-dns</feedburner:origLink></item><item><title>Manually testing SMTP mail issues via Telnet</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/b_vmpDS1SWU/manually-testing-smtp-mail-issues-via-telnet</link><description>&lt;p&gt;So this may be a post that exists in a million places on the web if you know where to look, however it would appear that whenever i do this a colleague gets the idea that i am channelling black magic. How does &lt;em&gt;one&lt;/em&gt; “debug” a mail server connection – this is as easy as 123.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="email-error-missing" border="0" alt="email-error-missing" align="right" src="http://www.diaryofaninja.com/asset/blogimages/email-error-missing_c2399bc2-ad89-45be-944c-d756bee14e5d.jpg" width="240" height="191" /&gt; This can be a complete life saver in times of need. Maybe your trying to get you site to send mail to a server that is not allowing relaying? Maybe your setting up a new mail server or debugging an old one? &lt;/p&gt;  &lt;p&gt;Who knows, who cares, lets get to it.&lt;/p&gt;  &lt;h3&gt;Steps:&lt;/h3&gt;  &lt;p&gt;1. Open a command window (we’re in windows… yes this may upset you, no i don’t care)&lt;/p&gt;  &lt;p&gt;2. Type:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;telnet youmailserver.com 25&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Syntax&lt;/h3&gt;  &lt;p&gt;Simply follow the conversation below to send a test email:&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="3" width="500"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="250"&gt;&lt;strong&gt;You type&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="250"&gt;&lt;strong&gt;The server responds&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="250"&gt;         &lt;p&gt;Telnet {youmailserver.com} 25&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="250"&gt;         &lt;p&gt;220 *Indentifying details*&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="250"&gt;         &lt;p&gt;HELO {yourdomainname.com}&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="250"&gt;         &lt;p&gt;250 *message*&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="250"&gt;         &lt;p&gt;MAIL FROM: {sender address}&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="250"&gt;         &lt;p&gt;250 is syntactically correct &lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="250"&gt;         &lt;p&gt;RCPT TO: {address to send to}&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="250"&gt;         &lt;p&gt;250 is syntactically correct           &lt;br /&gt;&lt;strong&gt;OR             &lt;br /&gt;&lt;/strong&gt;550 relaying denied&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="250"&gt;DATA&lt;/td&gt;        &lt;td valign="top" width="250"&gt;Tells you to send data&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="250"&gt;Subject: {your subject} ENTER         &lt;br /&gt;your message           &lt;br /&gt;ENTER&amp;#160; “.” ENTER&lt;/td&gt;        &lt;td valign="top" width="250"&gt;         &lt;p&gt;250 (message saying its added to queue)&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="250"&gt;QUIT (to disconnect)&lt;/td&gt;        &lt;td valign="top" width="250"&gt;A signoff message&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;h3&gt;Potential Errors&lt;/h3&gt;  &lt;p&gt;The conversation above may not play out exactly as described but it will definitely indicate if there is any issues from the clients’ point of view. If you receive messages about relaying being denied etc, you will quickly have a new avenue to investigate – this can be your silver bullet.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/b_vmpDS1SWU" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/02/17/manually-testing-smtp-mail-issues-via-telnet</feedburner:origLink></item><item><title>Why it&amp;rsquo;s FireFox, not IE that should be worried about Chrome</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/PTQOchMtDLk/why-itrsquos-firefox-not-ie-that-should-be-worried-about-chrome</link><description>&lt;p&gt;When &lt;a href="http://google.com/chrome" target="_blank"&gt;Chrome&lt;/a&gt; was first launched by Google, and the media found out about it, they proposed that Google had Microsoft firmly in it’s sights and was potentially about to start a new browser war, i beg to differ in my opinion on this. Internet Explorer has one major advantage that no other browser has, and for the near future at least, will continue to have: locked in marketshare in enterprise and all new copies of Windows. Internet Explorer will never be crushed. No matter how crap Internet Explorer becomes, it has the (some may say unfair, but i believe that’s life) advantage of already being installed 90% of the time. So who should really be afraid of Chrome spreading its wings? Apple and Mozilla and if you still care: Opera. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/browser%20wars_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="browser wars" border="0" alt="browser wars" align="right" src="http://www.diaryofaninja.com/asset/blogimages/browser%20wars_thumb.png" width="242" height="242" /&gt;&lt;/a&gt; Firefox is the easiest part of the market for Google to target and steal market share from, and so they stand to lose the most in this new browser war. I’m not going to really mention Opera here as they really lost the browser wars long ago and don't really have anything to lose unless your talking in the mobile space. &lt;/p&gt;  &lt;p&gt;Firefox is a user-installed piece of kit, which means IT departments around the world need to actually choose to put it into their installs, unlike Internet Explorer which is already there. Add to this the fact that most IT departments have a lot more to worry about than giving their users another browser, and you’ll see this is a pretty uncommon occurance in the corporate world. &lt;/p&gt;  &lt;p&gt;With that in mind, it is up to FireFox on it’s own to keep their product on the “must-have” list of software, or risk losing their underdog momentum. I must state at this point that i am very much a FireFox supporter, and have been for years. But the problem is the fact that the very reason i switched to FireFox – speed, stability and security, and add-ons – are the very reasons that people are now switching to Chrome, leading to a whole new generation of people looking to switch, potentially making the decision to go to Chome instead of FireFox.&lt;/p&gt;  &lt;p&gt;Apple of the other hand needs to fear chrome for other reasons, most strategic, although there are potential ways for them to lock more people into Safari, and one of these is iTunes – knowing Apple this is a likely move and should be expected, should they start to feel any threat from Chrome. As Safari, like most other Apple software on Windows (iTunes anyone???), gives users no real reason to switch, Chrome should have no problem in crushing that part of the market with minimum fuss.&lt;/p&gt;  &lt;p&gt;So in the end the company that really stands to lose the most from Chrome’s very existence is, in reality, FireFox. Seeing the browser is what holds Mozilla’s major market share, this may have bigger ramifications on the choices we are given for browsers in the future than we may think. The fact that Google pays FireFox a revenue share of all the searches from their browser allows you to see that FireFox’s future may rely heavily on how Google behaves as it starts to make waves in this market.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/PTQOchMtDLk" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/02/13/why-itrsquos-firefox-not-ie-that-should-be-worried-about-chrome</feedburner:origLink></item><item><title>6 Undocumented MSSQL stored procedures you may not know about</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/6e-2P-OZwo8/6-undocumented-mssql-stored-procedures-you-may-not-know-about</link><description>&lt;p&gt;There are quite a few built-in stored procedures in Microsoft's SQL Server that can help you troubleshoot database issues and make those long nights less painful. Knowing they exist can be a life saver, so lets take a look.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/easter%20egg_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="easter egg" border="0" alt="easter egg" align="right" src="http://www.diaryofaninja.com/asset/blogimages/easter%20egg_thumb.jpg" width="240" height="180" /&gt;&lt;/a&gt; As most web developers will know, if your not a DBA there are times when getting to the bottom of performance and database performance issues can be pain in the proverbial. Times like these it can be more than handy to have a few tricks up your sleave.&lt;/p&gt;  &lt;h3&gt;sp_MStablespace&lt;/h3&gt;  &lt;p&gt;The &lt;b&gt;sp_MStablespace&lt;/b&gt; stored procedure returns the number of rows in a table and the space the table and index use.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Usage&lt;/b&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;sp_MStablespace &lt;/span&gt;[table name]&lt;/pre&gt;

&lt;p&gt;To determine the space used by the &lt;b&gt;blogs &lt;/b&gt;table in the &lt;b&gt;mydb &lt;/b&gt;database, run:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;USE &lt;/span&gt;mydb
&lt;span style="color: blue"&gt;GO
EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;sp_MStablespace &lt;font color="#000000"&gt;blogs&lt;/font&gt;&lt;/span&gt;
&lt;span style="color: blue"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;strong&gt;Expected Results&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Rows        &lt;/span&gt;DataSpaceUsed IndexSpaceUsed
&lt;span style="color: green"&gt;----------- ------------- --------------
&lt;/span&gt;23          8             32&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;pre&gt;&amp;#160;&lt;/pre&gt;

&lt;h3&gt;sp_who2&lt;/h3&gt;

&lt;p&gt;The &lt;b&gt;sp_who2&lt;/b&gt; stored procedure returns information about current SQL Server users and processes similar to sp_who, but it provides a lot more information. The stored proc &lt;strong&gt;sp_who2&lt;/strong&gt; returns&amp;#160; the following columns: CPUTime, DiskIO, LastBatch and ProgramName in addition to the data provided by sp_who. This can be great when you want to get an instant report on what your SQL server is doing &lt;strong&gt;right now.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Usage&lt;/b&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;sp_who2&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;[optional, you can check on a single database user as below]&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;sp_who2 &lt;/span&gt;[database user]&lt;/pre&gt;

&lt;h3&gt;&amp;#160;&lt;/h3&gt;

&lt;h3&gt;xp_fileexist&lt;/h3&gt;

&lt;p&gt;The&lt;strong&gt; xp_fileexist&lt;/strong&gt; stored procedure returns information regarding the existence of a file path and whether&amp;#160; it is a file or a directory. Although this is basically useless in a job it can help when doing remote admin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;xp_fileexist &lt;/span&gt;&lt;span style="color: red"&gt;'[file path]'&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Expected results&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;File &lt;/span&gt;&lt;span style="color: gray"&gt;Exists &lt;/span&gt;&lt;span style="color: blue"&gt;File &lt;/span&gt;&lt;span style="color: gray"&gt;is &lt;/span&gt;a Directory   Parent Directory &lt;span style="color: gray"&gt;Exists
&lt;/span&gt;&lt;span style="color: green"&gt;----------- -------------------   -----------------------
&lt;/span&gt;1           0                     1
&lt;span style="color: gray"&gt;(&lt;/span&gt;1 row&lt;span style="color: gray"&gt;(&lt;/span&gt;s&lt;span style="color: gray"&gt;) &lt;/span&gt;affected&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h3&gt;&amp;#160;&lt;/h3&gt;

&lt;h3&gt;sp_MSforeachdb&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;sp_MSforeachdb&lt;/strong&gt; stored procedure can be used in jobs and queries that require you to loop through each database on the server. This can be great when coupled with queries that request stats on a database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage (this example executes the checkdb command)&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;sp_MSforeachdb &lt;/span&gt;@command1&lt;span style="color: gray"&gt;=&lt;/span&gt;&amp;quot;print '?' DBCC CHECKDB ('?')&amp;quot;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;sp_MSforeachtable&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;sp_MSforeachtable&lt;/strong&gt; can be used just like sp_MDforeachdb in the sense that you can use it to execute a command against each table in a database – this is great for checking the table size or row count of each table for example or any other task you want to run quickly run against all the tables in your DB.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;sp_MSForEachTable &lt;/span&gt;&lt;span style="color: red"&gt;'SELECT ''?'', COUNT(*) FROM ?'&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;sp_MSdependencies&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;sp_MSdependencies&lt;/strong&gt; stored procedure can be used to check all the objects in the database that are dependant on a table. If your unsuccessfully trying to delete a record that has dependencies because of foreign key that has rules applied to it this can be your answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;sp_msdependencies &lt;/span&gt;[table name]&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Expected Results&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;oType    oObjName    oOwner    oSequence
&lt;span style="color: green"&gt;-------- ----------- --------- ----------
&lt;/span&gt;8        tblAdmin    dbo        1&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/6e-2P-OZwo8" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/01/30/6-undocumented-mssql-stored-procedures-you-may-not-know-about</feedburner:origLink></item><item><title>How to use the Not-so-new MailSettingsSectionGroup</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/cLN0xZlZWT0/how-to-use-the-notsonew-mailsettingssectiongroup</link><description>&lt;p&gt;Today i came across something that from my day-to-day coding i have noticed a lot of my fellow coders at work/play have let slide on their path to .Net Mecca – using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.configuration.mailsettingssectiongroup.aspx"&gt;MailSettingsSectionGroup&lt;/a&gt; section of the web.config to specify both SMTP server host details as well as they other properties such as user/pass credentials in a central, single, easy to use manner. So I'll take this opportunity to make it as easy as possible for you to use.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="e-mail_icon" border="0" alt="e-mail_icon" align="right" src="http://www.diaryofaninja.com/asset/blogimages/e-mail_icon_84617800-508a-4670-be19-1d7adfbbab92.jpg" width="240" height="189" /&gt; Beginning in .Net 2.0 there was a new uniform group of settings added to web.config files. This allowed everyone to share a common place to store mail server settings, so that if you were using multiple applications running off the 1 web.config file, you didn’t have your mail server details &lt;a href="http://www.merriam-webster.com/dictionary/strewn"&gt;strewn&lt;/a&gt; in 10 different places in your application settings because every application used a different application setting name.&lt;/p&gt;  &lt;p&gt;If you haven’t been using it, you probably have still seen the below in your config files somewhere and continued stumbling into the night:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.net&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;mailSettings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;smtp&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;network &lt;/span&gt;&lt;span style="color: red"&gt;host&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;mail.mydomain.com&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;userName&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;myuser&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;password&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;mypass&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;smtp&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;mailSettings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.net&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;I have noticed that a lot of the guys at work (and from the OSS code I've seen around the place people outside my work) have not been using this settings group very much.&lt;/p&gt;

&lt;h3&gt;DIY&lt;/h3&gt;

&lt;p&gt;Using it is oh so very simple, and i’ll let the following simple mail sending code do the talking below:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;MailMessage &lt;/span&gt;email = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MailMessage&lt;/span&gt;();
email.From = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MailAddress&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;sender@sender.com&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;Sender's name&amp;quot;&lt;/span&gt;);
email.To.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MailAddress&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;recipient@recipient.com&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;Recipient's name&amp;quot;&lt;/span&gt;));
email.Body = &lt;span style="color: #a31515"&gt;&amp;quot;Hellow world&amp;quot;&lt;/span&gt;;
email.Subject = &lt;span style="color: #a31515"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;;

&lt;span style="color: #2b91af"&gt;Configuration &lt;/span&gt;c =
    &lt;span style="color: #2b91af"&gt;WebConfigurationManager&lt;/span&gt;.OpenWebConfiguration(&lt;span style="color: #2b91af"&gt;HttpContext&lt;/span&gt;.Current.Request.ApplicationPath);
&lt;span style="color: #2b91af"&gt;MailSettingsSectionGroup &lt;/span&gt;settings = 
    (&lt;span style="color: #2b91af"&gt;MailSettingsSectionGroup&lt;/span&gt;)c.GetSectionGroup(&lt;span style="color: #a31515"&gt;&amp;quot;system.net/mailSettings&amp;quot;&lt;/span&gt;);

&lt;span style="color: #2b91af"&gt;SmtpClient &lt;/span&gt;smtpClient = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SmtpClient&lt;/span&gt;(&lt;strong&gt;settings.Smtp.Network.Host&lt;/strong&gt;);
smtpClient.Credentials = &lt;span style="color: blue"&gt;new &lt;/span&gt;System.Net.&lt;span style="color: #2b91af"&gt;NetworkCredential&lt;/span&gt;(&lt;strong&gt;settings.Smtp.Network.UserName&lt;/strong&gt;,
                                                          &lt;strong&gt;settings.Smtp.Network.Password&lt;/strong&gt;);
smtpClient.Send(email);&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you’ll see in the code sample above that i’ve highlighted the settings that i wanted to draw attention to in &lt;strong&gt;bold&lt;/strong&gt;. The rest is pretty self explanatory, however you’ll note that it loads the subsection of the web.config for use in a serialized fashion&amp;#160; - this may give you some ideas for other uses :-)&lt;/p&gt;

&lt;h3&gt;Thar be Dragons!&lt;/h3&gt;

&lt;p&gt;Some people may take this opportunity to bring up the fact that having your email server credentials stored in a config file on your server is a security risk. I’d like to take this opportunity to point you in the direction of &lt;a href="http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx"&gt;encrypting parts of your web.config&lt;/a&gt;, as ASP.Net supports this natively.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/cLN0xZlZWT0" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/01/27/how-to-use-the-notsonew-mailsettingssectiongroup</feedburner:origLink></item><item><title>Manually publishing Internet Explorer 6 for use with Windows XP Mode</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/XjS40V3LNME/manually-publishing-internet-explorer-6-for-use-with-windows-xp-mode</link><description>&lt;p&gt;For those of you kiddies loving you Windows 7 goodness you may have discovered that from a web development point of view having an Internet Explorer 6 installation without much hassle is a pretty cool thing. Although the fact that you have to launch Windows Xp mode up and can’t use it as a “native” application by launching it from within Windows 7 is a bit of a let down. Let’s fix that :)&lt;/p&gt;  &lt;h3&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Virtual windows xp" border="0" alt="Virtual windows xp" align="right" src="http://www.diaryofaninja.com/asset/blogimages/Virtual%20windows%20xp_3.png" width="240" height="238" /&gt; A bit of background&lt;/h3&gt;  &lt;p&gt;Most web developers will tell you of the &lt;strong&gt;bane on our very existence&lt;/strong&gt; that is the continuation of internet explorer users in the world. Many different people get around with a version of &lt;a href="Windows XP Mode"&gt;Multi-IE&lt;/a&gt; or something similar so that they can do side by side comparisons. Another tool that seems to be getting traction is &lt;a href="http://browserlab.adobe.com/"&gt;Adobe’s Browser Lab&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Windows 7 brings a tool that a lot of people who don’t want to throw away their old software were pining for: &lt;a href="http://www.microsoft.com/windows/virtual-pc/download.aspx"&gt;Windows XP Mode&lt;/a&gt;. This allows you to run a virtual pc copy of Windows XP inside Windows 7 and cross publish applications so that they show up and can be launched from within windows 7 right from the program menu – pretty cool. It relies on some fandangled usage of remote desktop between the two to cover the gaps.&lt;/p&gt;  &lt;p&gt;The Windows XP mode image comes with Internet Explorer 6 installed on it by default which makes it a great way to check your sites in IE 6 without living in the dark ages. Sadly this is not published to the program menu of Windows 7 as it would probably make it quite confusing for the average-joe user, so you have to launch the Windows XP VM to access it. We’re going to change that :-)&lt;/p&gt;  &lt;h3&gt;Simple way&lt;/h3&gt;  &lt;h4&gt;&lt;strong&gt;Step 1.&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;Log into your XP mode machine&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;Step 2.&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;Right click on the start button and select “Open all users”&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;Step 3.&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;Right click inside the window and create a new shortcut pointing to &lt;strong&gt;C:\Program Files\Internet Explorer\iexplore.exe&lt;/strong&gt; and rename the shortcut &lt;strong&gt;Internet Explorer 6&lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h3&gt;A lit bit of trickery&lt;/h3&gt;  &lt;p&gt;So i got to looking for a way to publishing applications between the two and found that someone had already solved the problem with this simple &lt;a href="http://windowsitpro.com/Common/adforceimages/103347.html"&gt;vbscript&lt;/a&gt; which is based on the original technet article &lt;a href="http://blogs.technet.com/windows_vpc/archive/2009/11/02/publishing-virtual-applications-in-windows-virtual-pc.aspx"&gt;here&lt;/a&gt;. I have modified this to automatically publish Internet Explorer 6 from you Windows XP mode installation to Windows 7.&lt;/p&gt;  &lt;h3&gt;Show me the code!&lt;/h3&gt;  &lt;p&gt;Simply follow the steps below to make it all happen:&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; &lt;/h4&gt;  &lt;p&gt;Turn off Auto-Publish in your XP mode VM (Google is your friend)&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;Step 2.&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;Copy the following code into notepad in your Windows XP Mode VM and save as &lt;strong&gt;C:\PublishIE.vbs&lt;/strong&gt; (you can name it what you want but just remember where it is so you can replace it in the next step)&lt;/p&gt;  &lt;pre class="code"&gt;strComputer = &lt;span style="color: #a31515"&gt;&amp;quot;.&amp;quot;
&lt;/span&gt;strNamespace = &lt;span style="color: #a31515"&gt;&amp;quot;\root\cimv2\TerminalServices&amp;quot;
&lt;/span&gt;appName = &lt;span style="color: #a31515"&gt;&amp;quot;Internet Explorer 6 XP Mode&amp;quot;
&lt;/span&gt;appPath = &lt;span style="color: #a31515"&gt;&amp;quot;C:\Program Files\Internet Explorer\IEXPLORE.exe&amp;quot; 

&lt;/span&gt;&lt;span style="color: blue"&gt;set &lt;/span&gt;x = createobject(&lt;span style="color: #a31515"&gt;&amp;quot;Scriptlet.TypeLib&amp;quot;&lt;/span&gt;)
strNewGuid=Mid(x.GUID,2,8)

&lt;span style="color: blue"&gt;Set &lt;/span&gt;objSWbemServices = GetObject(&lt;span style="color: #a31515"&gt;&amp;quot;winmgmts:\\&amp;quot; &lt;/span&gt;&amp;amp; strComputer &amp;amp; strNamespace)
&lt;span style="color: blue"&gt;Set &lt;/span&gt;objSWbemObject = objSWbemServices.Get(&lt;span style="color: #a31515"&gt;&amp;quot;Win32_TSPublishedApplication&amp;quot;&lt;/span&gt;)
&lt;span style="color: blue"&gt;Set &lt;/span&gt;objNewSWbemObject = objSWbemObject.SpawnInstance_()

objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;) = appName  
objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;Alias&amp;quot;&lt;/span&gt;) = strNewGuid
objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;Path&amp;quot;&lt;/span&gt;) = appPath
objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;PathExists&amp;quot;&lt;/span&gt;) = &lt;span style="color: #a31515"&gt;&amp;quot;true&amp;quot;
&lt;/span&gt;objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;CommandLineSetting&amp;quot;&lt;/span&gt;) = &lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;
&lt;/span&gt;objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;RequiredCommandLine&amp;quot;&lt;/span&gt;) = &lt;span style="color: #a31515"&gt;&amp;quot;&amp;quot;
&lt;/span&gt;objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;IconIndex&amp;quot;&lt;/span&gt;) = &lt;span style="color: #a31515"&gt;&amp;quot;0&amp;quot;
&lt;/span&gt;objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;IconPath&amp;quot;&lt;/span&gt;) = appPath
objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;VPath&amp;quot;&lt;/span&gt;) = appPath
objNewSWbemObject.Properties_.Item(&lt;span style="color: #a31515"&gt;&amp;quot;ShowInPortal&amp;quot;&lt;/span&gt;) = &lt;span style="color: #a31515"&gt;&amp;quot;0&amp;quot;
&lt;/span&gt;objNewSWbemObject.Put_&lt;/pre&gt;

&lt;h4&gt;&lt;strong&gt;Step 3.&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;Open an elevated command prompt window and type the following:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;cscript C:\PublishIE.vbs&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Restart the VM&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/XjS40V3LNME" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/01/13/manually-publishing-internet-explorer-6-for-use-with-windows-xp-mode</feedburner:origLink></item><item><title>Developer productivity is important - Reality or Myth?</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/13QOGhMzqTQ/developer-productivity-is-important--reality-or-myth</link><description>&lt;p&gt;Today i was reading a post by &lt;a href="http://blog.wekeroad.com/2010/01/04/thoughts-on-aspnet-mvp--a-framework-that-wants-to-be-mvc"&gt;Rob Conery&lt;/a&gt; in which he discussed both his thoughts on developer productivity in relation to the creation of a new OS project (ASP MVP), and how he may have thought that in some instances hiding behind WebForms and not touching MVC was really just laziness or ignorance mistaken for productivity. Additionally i also read another post by &lt;a href="http://blog.scottbellware.com/2009/07/myth-of-developer-productivity.html"&gt;Scott Bellware&lt;/a&gt; in which talks about a similar subject, in that developer productivity when viewed in isolation, is really a myth.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="ILoveWebForms" border="0" alt="ILoveWebForms" align="right" src="http://www.diaryofaninja.com/asset/blogimages/ILoveWebForms_3.jpg" width="240" height="188" /&gt;While i think Rob may have been a bit aggressive in singling out someone's pride and joy (these guys have obviously put a lot of effort into this project so if they prefer their &lt;a href="http://en.wikipedia.org/wiki/Vegemite#Vegemite_Cheesybite:_new_recipe"&gt;I-Snack 2.0&lt;/a&gt; to their &lt;a href="http://www.vegemite.com.au/"&gt;Vegemite&lt;/a&gt;, all the more power to them), both these posts make some important points in relation to&lt;em&gt; short term&lt;/em&gt;,&lt;em&gt; long term&lt;/em&gt; and &lt;em&gt;invisible&lt;/em&gt; productivity for web developers (and others, but we’re talking about web developers today).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Sometimes spending less time creating a web page is not the best thing for the &lt;em&gt;web page&lt;/em&gt;&lt;/strong&gt;     &lt;br /&gt;I started web development outside of the WebForms world and believe that a lot of ASP.Net developers need to get out more, as sometimes using a atom bomb(webforms) when a stone(html page) will do the job has a much better long term result. If this means spending a bit more coding time, don’t whinge, do the right thing. I understand business is business and fastest can sometimes mean you keep your bosses happier but making the wrong call can bring other issues into the system that will add time somewhere else (refactoring, performance tuning etc).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Just because you can use a control in the designer that does what you need (as well as everything else) doesn’t mean you should use it      &lt;br /&gt;&lt;/strong&gt;Using a easy to use control in the search of productivity can be a mistake. Learning to use the right tool for the job is usually the best thing for the task at hand. This sometimes trying/learning something new.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;If taking up a new technology seems like a bad idea just because it has learning curve then maybe your priorities need readjustment&lt;/strong&gt;     &lt;br /&gt;Sometimes a better brand of &lt;a href="http://en.wikipedia.org/wiki/Kool-Aid"&gt;Kool-Aid&lt;/a&gt; comes along, and you may miss it simply because you &lt;em&gt;don’t have time&lt;/em&gt; to try it or because of any number of other reasons. If this &lt;a href="http://en.wikipedia.org/wiki/Kool-Aid"&gt;Kool-Aid&lt;/a&gt; was a new framework that could give you a lot of cool things that solve some problems the project has, and maybe also save development time then &lt;em&gt;making time&lt;/em&gt; may&lt;em&gt; save you time, &lt;/em&gt;and more importantly give you a better end product.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Sustainable productivity is the only productivity that matters&lt;/strong&gt;     &lt;br /&gt;If you have to rewrite something later because the tool wasn’t right for the job, or any other reason that comes down to your previous attempts at &lt;strong&gt;&lt;em&gt;gaining productivity&lt;/em&gt;&lt;/strong&gt; then it may be that your shooting yourself in the foot.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Productivity is about product&lt;/strong&gt;     &lt;br /&gt;The main goal as a developer is to create something great. This doesn’t always mean the easy or more familiar route. Sometimes it means the slow more complicated route or trying something new. Deciding the right tool for the job, really comes down to whether the &lt;em&gt;product&lt;/em&gt; in productivity has something to gain.&lt;/p&gt;  &lt;h3&gt;But some of those points contradict each other?!&lt;/h3&gt;  &lt;p&gt;This is where it gets tricky (or not so, depending on how you look at it). Working as a programmer/web developer/enlightened-one means that you have decided to make a career out of being the &lt;em&gt;go-to-guy&lt;/em&gt; when it comes to creamy web coding goodness. Your work is a reflection of &lt;strong&gt;You&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;I’m not saying that WebForms or MVC or HTML/JQUERY/WebServices is a better choice. Every project has different needs, and sometimes using one over the other (or reinventing the wheel in MVP’s case) is the right decision. Choosing based on taste/presumed productivity alone may be a simple folly.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/13QOGhMzqTQ" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2010/01/11/developer-productivity-is-important--reality-or-myth</feedburner:origLink></item><item><title>C# Convert DataSet to CSV</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/IWVeqnqP7Iw/c-convert-dataset-to-csv</link><description>&lt;p&gt;Today i found myself wanting to quickly export a dataset to CSV and i didn’t want to bloat of a library that does more than i need. The following method is the result of this need/want.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private string &lt;/span&gt;ConvertToCSV(&lt;span style="color: #2b91af"&gt;DataSet &lt;/span&gt;objDataSet)
{
    &lt;span style="color: #2b91af"&gt;StringBuilder &lt;/span&gt;content = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StringBuilder&lt;/span&gt;();

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(objDataSet.Tables.Count &amp;gt;= 1)
    {
        &lt;span style="color: #2b91af"&gt;DataTable &lt;/span&gt;table = objDataSet.Tables[0];

        &lt;span style="color: blue"&gt;if &lt;/span&gt;(table.Rows.Count &amp;gt; 0)
        {
            &lt;span style="color: #2b91af"&gt;DataRow &lt;/span&gt;dr1 = (&lt;span style="color: #2b91af"&gt;DataRow&lt;/span&gt;) table.Rows[0];
            &lt;span style="color: blue"&gt;int &lt;/span&gt;intColumnCount = dr1.Table.Columns.Count;
            &lt;span style="color: blue"&gt;int &lt;/span&gt;index=1;

            &lt;span style="color: green"&gt;//add column names
            &lt;/span&gt;&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;DataColumn &lt;/span&gt;item &lt;span style="color: blue"&gt;in &lt;/span&gt;dr1.Table.Columns)
            {
                content.Append(&lt;span style="color: #2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;&amp;quot;\&amp;quot;{0}\&amp;quot;&amp;quot;&lt;/span&gt;, item.ColumnName));
                &lt;span style="color: blue"&gt;if &lt;/span&gt;(index &amp;lt; intColumnCount)
                    content.Append(&lt;span style="color: #a31515"&gt;&amp;quot;,&amp;quot;&lt;/span&gt;);
                &lt;span style="color: blue"&gt;else
                    &lt;/span&gt;content.Append(&lt;span style="color: #a31515"&gt;&amp;quot;\r\n&amp;quot;&lt;/span&gt;);
                index++;
            }

            &lt;span style="color: green"&gt;//add column data
            &lt;/span&gt;&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;DataRow &lt;/span&gt;currentRow &lt;span style="color: blue"&gt;in &lt;/span&gt;table.Rows)
            {
                &lt;span style="color: blue"&gt;string &lt;/span&gt;strRow = &lt;span style="color: blue"&gt;string&lt;/span&gt;.Empty;
                &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;y = 0; y &amp;lt;= intColumnCount - 1; y++)
                {
                    strRow += &lt;span style="color: #a31515"&gt;&amp;quot;\&amp;quot;&amp;quot; &lt;/span&gt;+ currentRow[y].ToString() + &lt;span style="color: #a31515"&gt;&amp;quot;\&amp;quot;&amp;quot;&lt;/span&gt;;

                    &lt;span style="color: blue"&gt;if &lt;/span&gt;(y &amp;lt; intColumnCount - 1 &amp;amp;&amp;amp; y &amp;gt;= 0)
                        strRow += &lt;span style="color: #a31515"&gt;&amp;quot;,&amp;quot;&lt;/span&gt;;
                }
                content.Append(strRow + &lt;span style="color: #a31515"&gt;&amp;quot;\r\n&amp;quot;&lt;/span&gt;);
            }
        }
    }

    &lt;span style="color: blue"&gt;return &lt;/span&gt;content.ToString();
}&lt;/pre&gt;

&lt;h3&gt;Things to note:&lt;/h3&gt;

&lt;p&gt;- This won’t take care of field contents which contain double quotes, you may want to add support for this
  &lt;br /&gt;- This only exports the first table in a dataset 

  &lt;br /&gt;- Its pretty quick and nasty, so don’t blame me if you have issues&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/IWVeqnqP7Iw" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/12/16/c-convert-dataset-to-csv</feedburner:origLink></item><item><title>Adding Google &amp;lsquo;sounds like&amp;rsquo; to your sites search</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/47DHXr6rBl8/adding-google-lsquosounds-likersquo-to-your-sites-search</link><description>&lt;p&gt;It seems we live in an age where a lot of things are taken for granted on the web. Alternative spellings of things being offered to us when we search is a common example of this – simply look at Google and Bing’s “Did you mean X?” and you’ll know exactly what I'm talking about. At first though this can be seem quite daunting for the everyday web developer, but luckily Microsoft SQL server is here to save the day!&lt;/p&gt;  &lt;h3&gt;Microsoft doesn’t “SUCK TEH BIG TARM LOLZ”&lt;/h3&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="your_operating_system_sucks_trollcat" border="0" alt="your_operating_system_sucks_trollcat" align="right" src="http://www.diaryofaninja.com/asset/blogimages/your_operating_system_sucks_trollcat_3.jpg" width="240" height="223" /&gt; That’s right kids, once again the view that a lot of those PHP, Ruby and Mac player haters have couldn’t be further from the truth, the &lt;em&gt;evil&lt;/em&gt; Microsoft has some oober cool love to share and it is in the form of the &lt;a href="http://msdn.microsoft.com/en-us/library/ms187384.aspx"&gt;Soundex function&lt;/a&gt;, and if i don’t say so myself i think its pretty darn sweet.&lt;/p&gt;  &lt;p&gt;The way the Soundex function works is by converting a string to a code that represents its phonetics so that you can find similar words that may sound different. It does this by by ignoring all vowels.&lt;/p&gt;  &lt;h3&gt;It’s Doug not DUG!&lt;/h3&gt;  &lt;p&gt;This idea reminds me a lot of a Birthday card i got on my 5th birthday from one of my school friends. He spelt my name “Dug” on my birthday card and it pissed me off at the time to no end even though i was so young.&lt;/p&gt;  &lt;p&gt;A very simple way to test this out on the Soundex comman is to pull up a new query in SQL management studio and enter the following two lines&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;PRINT &lt;/span&gt;&lt;span style="color: magenta"&gt;soundex&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'doug'&lt;/span&gt;&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;PRINT &lt;/span&gt;&lt;span style="color: magenta"&gt;soundex&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'dug'&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Straight away you’ll probably get a little bit excited as you’ll see that they both come back with the result &lt;strong&gt;“D200”. &lt;/strong&gt;This means they both have the same phonetic signatures – cool huh?&lt;/p&gt;

&lt;h3&gt;Adding a search query to the mix&lt;/h3&gt;

&lt;p&gt;While the above function is cool when working with simple comparisons we want more than that. We want to take a query someone has entered and try and find a similar phrase from a table we have so that we can offer the user this ability.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;SELECT TOP &lt;/span&gt;1 &lt;span style="color: red"&gt;'Did you mean &amp;quot;' &lt;/span&gt;&lt;span style="color: gray"&gt;+ &lt;/span&gt;FirstName &lt;span style="color: gray"&gt;+ &lt;/span&gt;&lt;span style="color: red"&gt;'&amp;quot;?' &lt;/span&gt;&lt;span style="color: blue"&gt;AS SoundsLike
FROM &lt;/span&gt;tblNames
&lt;span style="color: blue"&gt;WHERE &lt;/span&gt;&lt;span style="color: magenta"&gt;SOUNDEX&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'Doug'&lt;/span&gt;&lt;span style="color: gray"&gt;) = &lt;/span&gt;&lt;span style="color: magenta"&gt;SOUNDEX&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;FirstName&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;The above example simply returns a string that says &lt;strong&gt;“Did you mean X?”&lt;/strong&gt; where &lt;strong&gt;X&lt;/strong&gt; is the &lt;strong&gt;FirstName&lt;/strong&gt; field of my table &lt;strong&gt;tblNames&lt;/strong&gt; with the search criteria looking for names that sound like &lt;strong&gt;Doug. &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Change this up for your own solution and your done!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/47DHXr6rBl8" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/11/29/adding-google-lsquosounds-likersquo-to-your-sites-search</feedburner:origLink></item><item><title>Are most everyday conversation&amp;rsquo;s all the same?</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/hsNlw1POZXU/are-most-everyday-conversationrsquos-all-the-same</link><description>&lt;p&gt;Today i was reading an article on the Sydney Morning Herald website by one of their travel bloggers. In it they asked the question “&lt;strong&gt;Have you noticed that backpackers tend to talk about the same things to world over?”&lt;/strong&gt; and it got me thinking something that i used to think quite a bit: “Are most conversations that people have the same ones everyday?”. A lot of developers I've worked with definitely fit this statement.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="conversation" border="0" alt="conversation" align="right" src="http://www.diaryofaninja.com/asset/blogimages/conversation_3.jpg" width="315" height="177" /&gt; The original blog article can be found @ &lt;a href="http://blogs.theage.com.au/travel/archives/2009/11/every_backpacker_conversation_ever.html" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The subject brought up in this article seem to be the case for a lot of 'stranger' talks when you bump into people.&lt;/p&gt;  &lt;p&gt;Meeting new people seems to happen this way in nearly every daily situation. Be it at work, with new friends you’ve just met or while out and about, or acquaintances you’ve bumped into&amp;#160; - nearly every &amp;quot;meeting&amp;quot; or a new person has a conversational flow that society seems to have put in place in a pre ordained fashion.&lt;/p&gt;  &lt;h3&gt;Conversation topics&lt;/h3&gt;  &lt;p&gt;Some that i can instantly think of without getting to much into it:&lt;/p&gt;  &lt;p&gt;- The weather   &lt;br /&gt;- Work    &lt;br /&gt;- Your weekend or upcoming weekend    &lt;br /&gt;- Relationships (in a mans case being under the thumb or in a woman’s case what the man does that annoys them)    &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;In the real world&lt;/h3&gt;  &lt;p&gt;I once had a theory that the people who socialise well, are really just the people who have had enough of these conversations previously that they know the routine well enough to keep good conversational flow.&lt;/p&gt;  &lt;p&gt;My partner Rachelle works as a teacher and has talked to me many times about kids with learning disabilities such as Autism. The often take things very literally when told something (don’t understand things like “get lost” as they take it as a direct command). The story goes that quite a lot of these kids grow up to be functional people suffering by learning to socialise by repetition. &lt;/p&gt;  &lt;p&gt;ie. they learn the general flow of the conversation and the rehearsed responses and are able to then take part in these conversations by giving the learnt responses in reply to the standard questions.&lt;/p&gt;  &lt;p&gt;As a developer a lot of the people I've worked with that have been incredibly intelligent have probably been edge cases that haven't spent a lot of time socialising or learning the importance of interaction – their conversation seems more like an Autistic child who has learnt to repeat conversations they’ve heard previously&lt;/p&gt;  &lt;p&gt;My real question here, after taking the above article and my own observations is:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“…Are the huge majority or conversations that people take part in, simply social interactions learnt in our overall development rather than active conversations?”&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In other words:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Rinse repeat...&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/hsNlw1POZXU" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/11/25/are-most-everyday-conversationrsquos-all-the-same</feedburner:origLink></item><item><title>Retrieve only the first record from a LEFT JOIN</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/AfGUK9BJawA/retrieve-only-the-first-record-from-a-left-join</link><description>&lt;p&gt;Recently I was working on a project where I had to return a simple list of products, and if they had images associated with them, return information about only one along with the product. Times like these, a simple left join or inner join just doesn’t cut it if there are more than one image/record per product. When this happens there is almost always a simple solution, so let’s take a look.&lt;/p&gt;  &lt;h3&gt;Thar be Dragons!&lt;/h3&gt;  &lt;p&gt;Too many times i have seen junior developers do silly things like run a SQL command on each iteration of a dataset loop. This will obviously end in slow ugly code that places a great amount of stress on your SQL server when there is no need. This is a very bad practice that should be avoided at all costs. &lt;/p&gt;  &lt;p&gt;Additionally this same outcomes can easily come from using an ORM tool badly when calling child objects or related objects (ie. some pseudo code like objProduct.Image[0].ImageSource). This is an equally bad mistake to make, but people seem to fall into it easily once they have their data layer abstracted far far away in another land as it may seem.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/Microsoft_SQL_Server_Logo_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Microsoft_SQL_Server_Logo" border="0" alt="Microsoft_SQL_Server_Logo" align="right" src="http://www.diaryofaninja.com/asset/blogimages/Microsoft_SQL_Server_Logo_thumb.png" width="250" height="70" /&gt;&lt;/a&gt; The SQL Prize is in the pudding&lt;/h3&gt;  &lt;p&gt;One option is to use a SQL sub query, which depending on your situation may also work. Our answer to the this niggling issue in this case is in the SQL statement OUTER APPLY. &lt;/p&gt;  &lt;p&gt;A quick Google will show you some cool examples and uses:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://weblogs.sqlteam.com/jeffs/archive/2007/06/12/60228.aspx" href="http://weblogs.sqlteam.com/jeffs/archive/2007/06/12/60228.aspx"&gt;http://weblogs.sqlteam.com/jeffs/archive/2007/06/12/60228.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.sqlteam.com/article/using-cross-apply-in-sql-server-2005" href="http://www.sqlteam.com/article/using-cross-apply-in-sql-server-2005"&gt;http://www.sqlteam.com/article/using-cross-apply-in-sql-server-2005&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;My example SQL&lt;/h3&gt;  &lt;p&gt;So as usual, lets get on with the show!&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;tblProducts&lt;span style="color: gray"&gt;.&lt;/span&gt;prodID&lt;span style="color: gray"&gt;, 
        &lt;/span&gt;tblProducts&lt;span style="color: gray"&gt;.&lt;/span&gt;prodName&lt;span style="color: gray"&gt;,
        &lt;/span&gt;tblProducts&lt;span style="color: gray"&gt;.&lt;/span&gt;prodDescription&lt;span style="color: gray"&gt;,
        &lt;/span&gt;tblImages&lt;span style="color: gray"&gt;.&lt;/span&gt;imgFileName
&lt;span style="color: blue"&gt;FROM &lt;/span&gt;tblProducts   
&lt;span style="color: gray"&gt;OUTER APPLY (  
    &lt;/span&gt;&lt;span style="color: blue"&gt;Select TOP &lt;/span&gt;1 images&lt;span style="color: gray"&gt;.&lt;/span&gt;imgFileName  
    &lt;span style="color: blue"&gt;From &lt;/span&gt;tblImages images 
    &lt;span style="color: blue"&gt;WHERE &lt;/span&gt;images&lt;span style="color: gray"&gt;.&lt;/span&gt;prodID &lt;span style="color: gray"&gt;= &lt;/span&gt;tblProducts&lt;span style="color: gray"&gt;.&lt;/span&gt;prodID  
    &lt;span style="color: gray"&gt;) &lt;/span&gt;tblImages&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/AfGUK9BJawA" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/11/17/retrieve-only-the-first-record-from-a-left-join</feedburner:origLink></item><item><title>C# reading an open text file in less than 10 lines</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/9Q2ScPyfku4/c-reading-an-open-text-file-in-less-than-10-lines</link><description>&lt;p&gt;There are times when you want to read a text file that is in use – or as i have had many times, code you have recently execute hasn’t fully let go of the file when you go to read it – when you copy something to a directory and the AV scans it or any other times when you want a file’s contents but don't want to have to worry about locks.&lt;/p&gt;  &lt;p&gt;This seems like a really simple thing to do and it is, so some people would say not worth a post – but i like posting code snippets that i think are handy for fellow Googlers so enjoy :-)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;strFilePath = &lt;span style="color: #a31515"&gt;&amp;quot;C:\test.txt&amp;quot;&lt;/span&gt;;
&lt;span style="color: blue"&gt;string &lt;/span&gt;strFileContents = &lt;span style="color: blue"&gt;string&lt;/span&gt;.Empty;

&lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;fileStream = &lt;span style="color: blue"&gt;new &lt;/span&gt;FileStream(importPath, FileMode.Open, FileAccess.Read))
{
    &lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;textReader = &lt;span style="color: blue"&gt;new &lt;/span&gt;StreamReader(fileStream))
    {
        strFileContents = textReader.ReadToEnd();
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please be aware that this will not work for files that have been marked by a process as to not be shared then this will still not work, but the point of me posting this code is more for those instances when the file&lt;em&gt; shouldn’t&lt;/em&gt; be locked but &lt;em&gt;is&lt;/em&gt; (those odd occasions that seem to be more common than odd)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/9Q2ScPyfku4" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/11/10/c-reading-an-open-text-file-in-less-than-10-lines</feedburner:origLink></item><item><title>Let there be Mo - Support Movember</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/m-hO1MJ-YCY/let-there-be-mo--support-movember</link><description>&lt;p&gt;It’s official kids, November, the month of the moustache, is going to be &lt;strong&gt;my&lt;/strong&gt; month of the moustache as well. I am taking part in the fundraising event known as Movember (&lt;a title="http://au.movember.com/" href="http://au.movember.com/"&gt;http://au.movember.com/&lt;/a&gt;) in which i will rejoice in the god given right of growing a porn star moustache. Movember is an international cause to raise money and awareness for Prostate Cancer and Male Depression. Time to get involved!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/magnumPI_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="magnumPI" border="0" alt="magnumPI" align="right" src="http://www.diaryofaninja.com/asset/blogimages/magnumPI_thumb.jpg" width="266" height="329" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Its not every day you get to be involved in something so epic so I'm quite excited. I’ve been wanting to contribute to society in some other way than making websites and this is a great chance.&lt;/p&gt;  &lt;h3&gt;The unknown&lt;/h3&gt;  &lt;p&gt;One of the things i found so amazing about &lt;a href="http://au.movember.com/" target="_blank"&gt;Movember’s&lt;/a&gt; main charity causes – Prostate Cancer – is just how little publicity it gets in every day society when compared to its female counter part, Breast cancer.&lt;/p&gt;  &lt;p&gt;Prostate cancer is the most common type of cancer that afflicts Australian men and the second highest cause of cancer deaths in men. Each year in Australia, close to 3000 men die of prostate cancer - equal to the number of women who die from breast cancer annually. Around 18,700 new cases are diagnosed in Australia every year.&lt;/p&gt;  &lt;p&gt;This means that there are thousands of men out there that aren’t making much noise about their illness or asking for help and attention. Like most things, talking about an illness is not considered a good male trait in society. While this masculine trend may continue for some time into the future, it is sad to know that their are a lot of men suffering silently.&lt;/p&gt;  &lt;p&gt;One in 9 men in Australia will develop prostate cancer in their lifetime. This is a crazy statistic. Lets say that again.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;One in 9 men men in Australia will develop prostate cancer&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This means that if you went to school or uni with a group of say 30 guys, 3 of them will get prostate cancer. This means you are going to be the odd one out if you&lt;strong&gt; don’t&lt;/strong&gt; know someone who gets it.&lt;/p&gt;  &lt;p&gt;What’s even more crazy is the fact that prostate cancer has a cure rate of over 90% if found early. This means that if us stubborn bastards can actually get off our asses and get to a doctor, we actually have a good chance of survival. So why do so many people still die every year? &lt;/p&gt;  &lt;p&gt;I don’t know, but I'm going to do my best to raise awareness of this cause so that maybe some men don’t have to suffer in future.&lt;/p&gt;  &lt;p&gt;If you would like to donate to &lt;a href="http://au.movember.com/" target="_blank"&gt;Movemeber&lt;/a&gt; either contact me using the form on this site, email me (doug[at]diaryofaninja.com) or donate directly using my Movember Mospace page:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://au.movember.com/mospace/49226"&gt;http://au.movember.com/mospace/49226&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I will try and post pics as my mo progresses :-)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/m-hO1MJ-YCY" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/10/28/let-there-be-mo--support-movember</feedburner:origLink></item><item><title>SubSonic, SQLite, Sonic.exe and 64bit, oh my!</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/beF05KqrdVU/using-subsonic-and-sqlite-on-a-64bit-development-machine</link><description>&lt;p&gt;Well this week i started work on my new development machine – a 64bit Windows 7 machine mmmm tasty. Everything has run perfectly smoothly until i hit one weird little issue. While attempting to generate a new data layer for a &lt;a href="http://www.sqlite.org/" target="_blank"&gt;SQLite&lt;/a&gt; database using &lt;a href="http://www.subsonicproject.com" target="_blank"&gt;Subsonic&lt;/a&gt; i received nothing but errors – Another simple fix which I'll show you in this post.&lt;/p&gt;  &lt;h3&gt;Another day, another drama&lt;/h3&gt;  &lt;p&gt;So there i was happily coding away, loving my oober quick build times and that overall &lt;em&gt;new machine&lt;/em&gt;&lt;strong&gt; &lt;/strong&gt;feel when i hit upon this snag. &lt;a href="http://www.subsonicproject.com" target="_blank"&gt;Subsonic’s&lt;/a&gt; &lt;strong&gt;sonic.exe &lt;/strong&gt;was building my DAL perfectly on all my SQL databases but i have one lightweight service that uses a SQLite database for its persistence. Subsonic is awesome because of the fact that it supports quite a few database types and SQLite is one of them. &lt;/p&gt;  &lt;p&gt;Subsonic does this by using the fantastic &lt;strong&gt;&lt;em&gt;System.Data.SQLite&lt;/em&gt;&lt;/strong&gt; library that can be found @ &lt;a title="http://sqlite.phxsoftware.com/" href="http://sqlite.phxsoftware.com/"&gt;http://sqlite.phxsoftware.com/&lt;/a&gt; – more specifically it uses the 32bit version 1.0.60 of the library. Now as anyone who builds for both 64bit and 32bit will tell you with .Net libraries, if you don’t specify a single platform, by default Visual Studio will build for both. This works great in most instances, however if your library contains a reference to a library that is built specifically for only one and your library loads in a different platform to the one required by the reference, an exception will be thrown.&lt;/p&gt;  &lt;pre class="code"&gt; ERROR: Trying to execute generate

Error Message: System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. 
An attempt was made to load a program with an incorrect format.

File name: 'System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'
   at SubSonic.SQLiteDataProvider.GetTableNameList()
   at SubSonic.SubCommander.Program.GenerateTables() in D:\@SubSonic\SubSonic\SubCommander\Program.cs:line 902
   at SubSonic.SubCommander.Program.GenerateAll() in D:\@SubSonic\SubSonic\SubCommander\Program.cs:line 789
   at SubSonic.SubCommander.Program.Main(String[] args) in D:\@SubSonic\SubSonic\SubCommander\Program.cs:line 90

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.

To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].&lt;/pre&gt;

&lt;h3&gt;How can we fix it?&lt;/h3&gt;

&lt;p&gt;Well the issue in this instance is the fact that the System.Data.SQlite version that is packaged with Subsonic is a 32bit version. This makes the fix a simple one: simply replace the version in your sonic.exe folder with a 64bit one.&lt;/p&gt;

&lt;p&gt;Your first step should be to go and download a copy of the 1.0.60 build of the System.Data.SQLite library. &lt;/p&gt;

&lt;p&gt;At the time of writing it can be found here and you want to get the &lt;a href="http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/1.0.60.0/SQLite-1.0.60.0-binaries.zip/download"&gt;SQLite-1.0.60.0-binaries.zip&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a title="http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/" href="http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite for ADO.NET 2.0/"&gt;http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite for ADO.NET 2.0/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The System.Data.SQLite library used by subsonic is stored in the same folder as the sonic.exe, if you originally used the Subsonic 2.1 Installer this will but the library in one of the following locations (if not it will be in the folder you put it in):&lt;/p&gt;

&lt;p class="code"&gt;32bit systems: 
  &lt;br /&gt;C:\Program Files\Subsonic\SubCommander\ 

  &lt;br /&gt;

  &lt;br /&gt;64bit systems: 

  &lt;br /&gt;C:\Program Files (x86)\Subsonic\SubCommander\ &lt;/p&gt;

&lt;p&gt;All you need to do is replace the file &lt;strong&gt;&lt;em&gt;System.Data.SQLite.dll&lt;/em&gt;&lt;/strong&gt; with the one from the 64bit version of the build folder in the zip you downloaded.&lt;/p&gt;

&lt;p&gt;Run Sonic.exe however you like (i use the visual studio extra’s way as outlined &lt;a href="http://subsonicproject.com/docs/Setting_up_SubSonic_2.x" target="_blank"&gt;here&lt;/a&gt;) and your done!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/beF05KqrdVU" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/10/25/using-subsonic-and-sqlite-on-a-64bit-development-machine</feedburner:origLink></item><item><title>Are software developers naturally weird?</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/mWGA6IKYKSw/are-software-developers-naturally-weird</link><description>&lt;p&gt;I was recently read a &lt;a href="http://itmanagement.earthweb.com/features/article.php/3844291/Are-Software-Developers-Naturally-Weird.htm" target="_blank"&gt;blog post&lt;/a&gt; recently by Eric Spiegel, that made it to &lt;a href="http://slashdot.org" target="_blank"&gt;Slashdot&lt;/a&gt; where he asked the question: “Are software developers naturally weird?”. I think deep down everyone who works in IT is a bit weird, and i will repeat Eric’s remark: “Go on admit it”. Whether it is something tiny or their complete character, you can usually put your finger on something out of the ordinary. My REAL question is: Is everyone weird in some way once you get close to them?&lt;/p&gt;  &lt;p&gt;My own experiences show that he may be onto something. I’ve had quite a few odd work colleagues and find myself also thinking oddly about certain mannerisms that i myself have started to portray. Is our inner weirdo what makes us so good at what we do? Is our day to day job potentially also bringing/creating these traits to us anew?&lt;/p&gt;  &lt;p&gt;The thing about work colleagues is that you spend more time with them than you do with the people you love. Whether you like it or not they usually make up the most part of your life – even if you can’t wait to get away from them at the end of the day.&lt;/p&gt;  &lt;h3&gt;Young man in old mans body boss&lt;/h3&gt;  &lt;p&gt;One of the first roles i had as a software developer was for a boss in his early 50’s who seemed to have a hard dealing with the fact that he wasn’t as young as he once was. &lt;/p&gt;  &lt;p&gt;He rode his bike to work and loved prancing around in his bike pants before and after riding just to let us know he was riding his bike. There is nothing worse than trying to debug code at the end of a long day with someone wearing bike pants with a padded crotch standing over your shoulder just a little bit too close (read: your shoulder being rubbed now and then by crotch)&lt;/p&gt;  &lt;p&gt;This seemed to be a contradiction in the sense that while reminding us how young at heart he was in different ways multiple times daily he would also, on the flip side, love to tell us how he’d used punch cards to write code “back in the day” as well as reminding us how he had been one of the few Australians to get Netscape 1 when it came out.&lt;/p&gt;  &lt;p&gt;But the worst part was when he wanted to prove his coding abilities even though he was in management. Whenever there was an issue or bug that was taking the team a while to sort out he would bounce into the room announcing &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“Step aside and let the lion teach the cub some new tricks” &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I’ll just say that he didn’t really help us very much… ever.&lt;/p&gt;  &lt;h3&gt;Smelly lunch guy&lt;/h3&gt;  &lt;p&gt;Another weird developer that i have worked with in the past was a recent immigrant from China who was 20 and very socially unaware. He was a great guy and thankfully didn’t take himself too seriously – his work was top notch too.&lt;/p&gt;  &lt;p&gt;The problems started really on his first day. His girl friend made him lunch everyday and he BYO’d. I have worked with many Asian people over the years and am very used to the great foods they make, as well as jealousy looking on as they show today's gourmet meal, usually provided for them by their partners (lucky guys… hint hint - Rachelle? lol)&lt;/p&gt;  &lt;p&gt;On his first day he brought in some giant king prawns, rice and chicken – and heated it in our works’ kitchenette microwave. Strangely the combination of this food and a microwave made the smell that wafted from it so strong that it made it almost impossible to stay in the board room where everyone who BYO’d ate lunch (a large room), and everyone (even the other Asian staff) soon quietly left. This continued for a couple of weeks before management let him know that it was inappropriate for him to continue as we used the room for client meetings. Every day after this he would grumble about how management had made him stop and how unfair it was – in fact any time food was brought up he had a grumble (late night pizza anyone?).&lt;/p&gt;  &lt;p&gt;Still to this day i have no idea how his food always reeked so badly – never before or after have i smelt food that bad.&lt;/p&gt;  &lt;h3&gt;Uptight ninja&lt;/h3&gt;  &lt;p&gt;One of the hardest guys that i have had to work with was actually also one of the smartest guys I've ever had to privilege of being around. If your reading this you know who you are.&lt;/p&gt;  &lt;p&gt;The guy was extremely uptight and would always jump to the negative side of everything, usually while quietly mumbling crazily to himself and fiddling with things. Whenever a client would ask for something that was out of the ordinary, it seemed to make him completely freak out. He would always find a way to offer the solution and it would usually push the guys around him into learning something new and cool, but the amount of stress he seemed to place on himself was almost like he was experiencing an autistic outburst. I feel bad to say it but it was quite funny to be around, while at the same time you wished you could calm him down.&lt;/p&gt;  &lt;h3&gt;My own issues&lt;/h3&gt;  &lt;p&gt;Well i may be going out on a limb here but a number of traits of my own have started to come to my attention.&lt;/p&gt;  &lt;p&gt;Sometimes (Rachelle would like to think more than just &lt;em&gt;sometimes&lt;/em&gt;) i start lines of conversation with people that are close to me and drift off before i finish. This happens a lot while coding or watching TV. A lot of the people who know me have gotten used to this trait and simply ignore it - sometimes i may continue the conversation many minutes later where i left off leaving people wondering what the hell I'm talking about as it was so long since I'd left the conversation.&lt;/p&gt;  &lt;p&gt;Another thing that i find myself doing is dreaming of code. This happens a lot when I’m under pressure at work or am having problems solving something. The worst case of this happens when i am ill with a fever, can’t sleep or am having feverish sleep. This is the worst as code becomes a nightmare problem that can’t be solved, even if i know the answer i have repetitive issues where the code doesn’t work.&lt;/p&gt;  &lt;h3&gt;Your thoughts?&lt;/h3&gt;  &lt;p&gt;What odd work colleague experiences have you had? And is it just software people, IT people or everyone who at the end of the day once you get to know them are weird?&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/mWGA6IKYKSw" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/10/21/are-software-developers-naturally-weird</feedburner:origLink></item><item><title>Retrieving a Flickr Photo ID from a URL using RegEx</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/yZp6C4VbXT4/retrieving-a-flickr-photo-id-from-a-url-using-regex</link><description>&lt;p&gt;While working on a recent Flickr/Google Maps mashup i needed to make it as simple for users to share their Flickr photos as possible. What is easier than simply asking them to enter the Flickr photo page URL? Using this I'll show you a simple way to use RegEx to retrieve the photo ID part of the URL using c# as well as a JavaScript RegEx version for your ASP.Net RegEx validators. Lets get to it!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/logo_home.png.v2_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="logo_home.png.v2" border="0" alt="logo_home.png.v2" align="right" src="http://www.diaryofaninja.com/asset/blogimages/logo_home.png.v2_thumb.png" width="162" height="64" /&gt;&lt;/a&gt; So there is two parts to this post: The code used to retrieve the Flickr image ID from the photo page URL as well as the JavaScript version to simply check to see that the user has entered a valid &lt;a href="http://www.flickr.com" target="_blank"&gt;Flickr&lt;/a&gt; photo page URL without having to postback.&lt;/p&gt;  &lt;h3&gt;Spoiler Alert&lt;/h3&gt;  &lt;p&gt;If you are simply after the regular expression to get the Flickr Image ID and don’t want to read all my waffle below (i like your style) then I'll save you the trouble.&lt;/p&gt;  &lt;p&gt;.Net Regular Expression with grouping:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: #a31515"&gt;photos/[^/]+/(?&amp;lt;imgID&amp;gt;[0-9]+)&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;JavaScript Regular Expression&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #a31515"&gt;photos/[^/]+/([0-9]+)&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h3&gt;The photo page URL format&lt;/h3&gt;

&lt;p&gt;Flickr’s photo pages use the following URL format:&lt;/p&gt;

&lt;p class="code"&gt;http://www.flickr.com/photos/[FLICKR USERNAME]/[FLICKR PHOTO ID]/&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;For those of you retrieving Flickr photos from Flickr using their API (i love &lt;a href="http://www.codeplex.com/FlickrNet" target="_blank"&gt;FlickrNet&lt;/a&gt; for retrieving images using .Net – check it out) you’ll know that usually you want to know the Flickr photo ID (the second part of the URL) to do anything with the image using the API. So we need a regular expression that will extract the photo ID part of the above URL. &lt;/p&gt;

&lt;p&gt;We could do this a number of other ways but i like RegExs for their power and simplicity.&lt;/p&gt;

&lt;h3&gt;How to validate a valid URL has been entered&lt;/h3&gt;

&lt;p&gt;As everyone developer has gathered the knowedge over time: Users can be stupid. Therefore if we have a user entering their photo URL’s we want to make suer that they have entered a valid URL before they do a postback to save them time. &lt;/p&gt;

&lt;p&gt;Using the JavaScript RegEx i have provided above it is quite simple to just add a Regular Expression validator to your entry page to check the field for a valid URL. I have provided an example below.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;RegularExpressionValidator &lt;/span&gt;&lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;RegularExpressionValidator1&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;server&amp;quot; 
    &lt;/span&gt;&lt;span style="color: red"&gt;ControlToValidate&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;txtPhotoURL&amp;quot; 
    &lt;/span&gt;&lt;span style="color: red"&gt;ErrorMessage&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;You must enter a valid Flickr URL&amp;quot; 
    &lt;/span&gt;&lt;span style="color: red"&gt;ValidationExpression&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;photos/[^/]+/([0-9]+)&amp;quot;&amp;gt;&lt;/span&gt;*&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;RegularExpressionValidator&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h3&gt;Retrieving the value in c#&lt;/h3&gt;

&lt;p&gt;So now that we know that the user has entered a valid Flickr photo URL using the above regular expression validator we want to extract just the image ID from the string for use. As i mentioned above i have used a regular expression grouping to give my photo ID an easy to reference name – so lets get it out.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;Match &lt;/span&gt;match = &lt;span style="color: #2b91af"&gt;Regex&lt;/span&gt;.Match(flickrURL, &lt;span style="color: #a31515"&gt;&amp;quot;photos/[^/]+/(?&amp;lt;imgID&amp;gt;[0-9]+)&amp;quot;&lt;/span&gt;,
                          &lt;span style="color: #2b91af"&gt;RegexOptions&lt;/span&gt;.IgnoreCase | 
                          &lt;span style="color: #2b91af"&gt;RegexOptions&lt;/span&gt;.Singleline);
&lt;span style="color: blue"&gt;if &lt;/span&gt;(match.Success)
{
   &lt;span style="color: blue"&gt;string &lt;/span&gt;FlickrPhotoID = match.Groups[&lt;span style="color: #a31515"&gt;&amp;quot;imgID&amp;quot;&lt;/span&gt;].Value;
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Too easy!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/yZp6C4VbXT4" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/10/18/retrieving-a-flickr-photo-id-from-a-url-using-regex</feedburner:origLink></item><item><title>Consuming an ASP.Net WebService with Jquery &amp;amp; JSON</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/1hUvkj40ZS8/consuming-an-aspnet-webservice-with-jquery-amp-json</link><description>&lt;p&gt;ASP.Net Script Services and Web Services are an incredibly powerful tool for providing rich dynamic sites using AJAX. As good as they are, there are times when you want to access them in alternate ways. Combine JQuery, JSON and ASP.Net Web Services and you have a combination that rivals the A Team – lets take a look.&lt;/p&gt; &lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/kAPXGuRIXsA&amp;amp;hl=en&amp;amp;fs=1&amp;amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/kAPXGuRIXsA&amp;amp;hl=en&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;h3&gt;Quit your jibber jabber&lt;/h3&gt;  &lt;p&gt;While keeping my previous comments about this powerful combination in mind remember this: If there is one thing that the new snickers ads should teach you its that if you act like a girly man you’ll have Mr T drive a tank at you while making comments about your manhood and throwing snickers at you. This applies to many things, so lets get into it!&lt;/p&gt;  &lt;p&gt;Something that a lot of people don’t understand properly is that ASP.Net Web Services do a lot of funky things. One of these is returning things as pure JSON… mmm. That's right kids, strongly typed JavaScript web services.&lt;/p&gt;  &lt;h3&gt;What you’ll need to do&lt;/h3&gt;  &lt;h4&gt;1. Add JQuery to the page consuming the web service. &lt;/h4&gt;  &lt;p&gt;I recommend the much publicised Google API method to achieve this, and use their CDN to speed up jquery’s load time significantly. Its so simple and offers the download from their servers – this is a good thing.&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;head&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot; &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: red"&gt;src&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;head&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h4&gt;2. Add your script manager to your page and reference your web service(mine is a local file).&lt;/h4&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;ScriptManager &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;scriptmgr&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;server&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Services&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;ServiceReference  &lt;/span&gt;&lt;span style="color: red"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;~/MyWebservice.asmx&amp;quot; /&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Services&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;ScriptManager&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h4&gt;3. Setup you Web Service as a Script Service&lt;/h4&gt;

&lt;p&gt;Firstly i would like to show a sample of my simple WebService’s one method. As you’ll note i have marked it’s method as a [ScriptMethod] so that it can be accessed by script as well as marking the service as a [ScriptService].&lt;/p&gt;

&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;WebService&lt;/span&gt;(Namespace = &lt;span style="color: #a31515"&gt;&amp;quot;http://tempuri.org/&amp;quot;&lt;/span&gt;)]
[&lt;span style="color: #2b91af"&gt;ScriptService&lt;/span&gt;]
&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyWebservice &lt;/span&gt;: System.Web.Services.&lt;span style="color: #2b91af"&gt;WebService
&lt;/span&gt;{
    [&lt;span style="color: #2b91af"&gt;WebMethod&lt;/span&gt;]
    [&lt;span style="color: #2b91af"&gt;ScriptMethod&lt;/span&gt;]
    &lt;span style="color: blue"&gt;public string &lt;/span&gt;GetName(&lt;span style="color: blue"&gt;string &lt;/span&gt;firstName, &lt;span style="color: blue"&gt;string &lt;/span&gt;lastName)
    {  &lt;br /&gt;&lt;span style="color: #2b91af"&gt;       MyReturnObject &lt;/span&gt;output = 
          &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyReturnObject&lt;/span&gt;(firstName,lastName)&lt;br /&gt;       &lt;span style="color: blue"&gt;return &lt;/span&gt;output;&lt;br /&gt;    }
}&lt;br /&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyReturnObject
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;public &lt;/span&gt;MyReturnObject(&lt;span style="color: blue"&gt;string &lt;/span&gt;firstName, &lt;span style="color: blue"&gt;string &lt;/span&gt;lastname)
    {
        FirstName = firstName;
        LastName = lastname;
    }
    &lt;span style="color: blue"&gt;public string &lt;/span&gt;FirstName;
    &lt;span style="color: blue"&gt;public string &lt;/span&gt;LastName;
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h4&gt;4. Access our service using jquery&lt;/h4&gt;

&lt;p&gt;Now this is the real fun part. As something that usually may be a bit of a round the block ordeal if you returning large amounts of data from your Web Service, JQuery sticks to its word to and comes up trumps with “Write less, do more”. &lt;/p&gt;

&lt;p&gt;Things to note:&lt;/p&gt;

&lt;p&gt;- the data parameters are CaseSensitive
  &lt;br /&gt;- this will only work for local web services

  &lt;br /&gt;- you’ll note that i point at both the web service AND its method name after the /

  &lt;br /&gt;- make note that i have set the dateType as JSON so that our webservice will return as JSON not XML&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt;
&lt;/span&gt;$(document).ready(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
     $.ajax({  
       type: &lt;span style="color: #a31515"&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;,  
       url: &lt;span style="color: #a31515"&gt;&amp;quot;/MyWebservice.asmx/GetName&amp;quot;&lt;/span&gt;,  
       contentType: &lt;span style="color: #a31515"&gt;&amp;quot;application/json; charset=utf-8&amp;quot;&lt;/span&gt;,  
       data: &lt;span style="color: #a31515"&gt;&amp;quot;{'firstName':'John','lastName':'Doe'}&amp;quot;&lt;/span&gt;,  
       dataType: &lt;span style="color: #a31515"&gt;&amp;quot;json&amp;quot;&lt;/span&gt;,  
       success: &lt;span style="color: blue"&gt;function&lt;/span&gt;(msg){
        &lt;span style="color: blue"&gt;var &lt;/span&gt;results = (&lt;span style="color: blue"&gt;typeof &lt;/span&gt;msg.d) == &lt;span style="color: #a31515"&gt;'string' &lt;/span&gt;? 
            eval(&lt;span style="color: #a31515"&gt;'(' &lt;/span&gt;+ msg.d + &lt;span style="color: #a31515"&gt;')'&lt;/span&gt;) : eval(msg);
        alert(&lt;span style="color: #a31515"&gt;&amp;quot;Hello, &amp;quot;&lt;/span&gt;+results.FirstName+&lt;span style="color: #a31515"&gt;&amp;quot; &amp;quot;&lt;/span&gt;+results.LastName);
       },  
       error: &lt;span style="color: blue"&gt;function&lt;/span&gt;(){
        alert(&lt;span style="color: #a31515"&gt;&amp;quot;There was an error&amp;quot;&lt;/span&gt;);
       }  
   });
});
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/1hUvkj40ZS8" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/10/12/consuming-an-aspnet-webservice-with-jquery-amp-json</feedburner:origLink></item><item><title>Adding Windows Live Writer support to your Blog engine</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/xfXb2SWSbRg/adding-windows-live-writer-support-to-your-blog-engine</link><description>&lt;p&gt;If there is one blogging related tool that I've come across lately that i think has been a game changer it would have to be Windows Live Writer. However some people are using either a custom written blog engine (like me) or are using a blog engine that doesn’t support Live Writer. If that is the case i will show you a simple way to integrate Windows Live Writer support into you blog with WebServices and the MetaWebLog API.&lt;/p&gt;  &lt;p&gt;So there i was coding away, minding my own business trying to get this blog off the ground and my mind wandered and one of my adventures into the forever continuing void that is “surfing the net” happened. &lt;/p&gt;  &lt;p&gt;As most people will relate to, working on the internet can be a dangerous thing when it come to distraction, and I'm no patron saint. Lucky for me i have a fetish for .Net blog articles and therefore can sometimes (well i like to think so) justify my distractions. It was then that i came across Scott Hanselman’s new &lt;a href="http://www.hanselman.com/blog/ScottHanselmans2009UltimateDeveloperAndPowerUsersToolListForWindows.aspx" target="_blank"&gt;Ultimate tools list&lt;/a&gt;, and he mentioned &lt;a href="http://download.live.com/writer" target="_blank"&gt;Windows Live Writer&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I thought:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Well, i am new to the web 2.0 blogging thing, and usually i think things Microsoft create to try and value add can just be because they like to have every finger in every pie, and in reality are just pretty crap...&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;I was wrong…&lt;/h3&gt;  &lt;p&gt;I downloaded and installed it and hit a brick wall. My new oober cool blog (this one) was not on the list of supported blog types (how rude). But i did see one cool thing on the list: &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="file:///C:/Users/Doug/AppData/Local/Temp/WindowsLiveWriter1286139640/supfiles1EBF41E1/LiveWriter017.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="LiveWriter01_thumb3" border="0" alt="LiveWriter01_thumb3" src="http://www.diaryofaninja.com/asset/blogimages/LiveWriter01_thumb3_c9ed3336-f614-42de-8921-bcd137231ec2.png" width="460" height="394" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;MetaWebLog API&lt;/h3&gt;  &lt;p&gt;That’s right kids. Its called &lt;a href="http://en.wikipedia.org/wiki/MetaWeblog" target="_blank"&gt;Metaweblog API&lt;/a&gt;. And iisssssss daaaa besttttt. &lt;/p&gt;  &lt;p&gt;Basically it allows you to write your weblog to support Windows Live Writer (and other tools) for managing, editing and publishing your blog posts. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;This is pretty epic.&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Although i must add at this point that i hadn’t had the glory of actually using it (Windows Live Writer) yet so i was just going off what other people had said and i didn’t really know how much this was a bonus. So I was bored and home one night and decided to jump right in and simply make it happen so that i could check out Windows Live Writer – i know this sounds silly but i love trying new things for fun.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“On Ya Bike Son”&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So off i went. Looking into some info &lt;a href="http://www.xmlrpc.com/metaWeblogApi" target="_blank"&gt;here&lt;/a&gt;, &lt;a href="http://www.pluralsight.com/community/blogs/aaron/archive/2008/08/19/programming-the-metaweblog-api-in-net-c.aspx" target="_blank"&gt;here&lt;/a&gt; and a few more readings on “da intarnetz” i was on my way to adding MetaWebLog API support to my blog. It is remarkably simple.&lt;/p&gt;  &lt;h3&gt;Steps&lt;/h3&gt;  &lt;p&gt;1. Create a new Generic Handler in your project    &lt;br /&gt;2. Create new methods to support the API     &lt;br /&gt;3. Wire-up these methods with your data layer     &lt;br /&gt;4. Connect to your new endpoint using Windows Live Writer     &lt;br /&gt;5. Enjoy your new blogging abilities &lt;/p&gt;  &lt;p&gt;All you’ll need is a copy of the Cook Computer XML RPC Library from &lt;a href="http://www.xml-rpc.net/" target="_blank"&gt;here&lt;/a&gt; and your off.&lt;/p&gt;  &lt;p&gt;&lt;a href="file:///C:/Users/Doug/AppData/Local/Temp/WindowsLiveWriter1286139640/supfiles1EBF41E1/ShowMeTheMoney1.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ShowMeTheMoney_thumb" border="0" alt="ShowMeTheMoney_thumb" src="http://www.diaryofaninja.com/asset/blogimages/ShowMeTheMoney_thumb_fed90bef-b57b-45a8-aeb6-089b6782a626.jpg" width="400" height="216" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So if you like me, you want example code, and you want it now. You’ve listened to me blab and want to get onto it yourself. So here is my minimised version of my handler – I've defined all the important RPC parts so you can reuse them easily. &lt;/p&gt;  &lt;p&gt;If something needs clarification, post a comment and I'll add to my code:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Linq;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Text;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.Compilation;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI;
&lt;span style="color: blue"&gt;using &lt;/span&gt;CookComputing.XmlRpc;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.IO;
&lt;span style="color: blue"&gt;namespace &lt;/span&gt;Ninja.WebServices
{
[&lt;span style="color: #2b91af"&gt;XmlRpcService&lt;/span&gt;(
    Name = &lt;span style="color: #a31515"&gt;&amp;quot;Your Blog Name :-)&amp;quot;&lt;/span&gt;,
    Description = &lt;span style="color: #a31515"&gt;&amp;quot;This is my XML RPC implementation of MetaWebLog API&amp;quot;&lt;/span&gt;,
    AutoDocumentation = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]
&lt;span style="color: green"&gt;//Change this to your endpoint URL
&lt;/span&gt;[&lt;span style="color: #2b91af"&gt;XmlRpcUrl&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;http://www.blog.com/LiveWriter&amp;quot;&lt;/span&gt;)] 
&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MetaBlogApi &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;XmlRpcService
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;private static void &lt;/span&gt;CheckLoggedIn(&lt;span style="color: blue"&gt;string &lt;/span&gt;username, &lt;span style="color: blue"&gt;string &lt;/span&gt;password)
    {
        &lt;span style="color: blue"&gt;bool &lt;/span&gt;loggedin = &lt;span style="color: blue"&gt;true&lt;/span&gt;;
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(!loggedin)
            &lt;span style="color: blue"&gt;throw new &lt;/span&gt;System.Security.Authentication
                .&lt;span style="color: #2b91af"&gt;InvalidCredentialException&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;Access denied&amp;quot;&lt;/span&gt;);
    }
[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;blogger.getUsersBlogs&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[] getUsersBlogs(&lt;span style="color: blue"&gt;string &lt;/span&gt;appKey, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;password)
{
    CheckLoggedIn(username,password);
    &lt;span style="color: green"&gt;//Uses xslt transformation to retrive recent posts
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[] posts = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[1];
    &lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;rpcstruct = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;();

    &lt;span style="color: green"&gt;//if you have more than one blog then loop them here
    &lt;/span&gt;rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;blogid&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;blogName&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;My blog name&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;http://www.myblog.com&amp;quot;&lt;/span&gt;); &lt;span style="color: green"&gt;// Blog URL
    &lt;/span&gt;posts[0] = rpcstruct;
    &lt;span style="color: blue"&gt;return &lt;/span&gt;posts;
}
[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;metaWeblog.setTemplate&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public bool &lt;/span&gt;setTemplate(&lt;span style="color: blue"&gt;string &lt;/span&gt;appKey, &lt;span style="color: blue"&gt;string &lt;/span&gt;blogid, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;password, &lt;span style="color: blue"&gt;string &lt;/span&gt;template, &lt;span style="color: blue"&gt;string &lt;/span&gt;templateType)
{
    &lt;span style="color: green"&gt;//WINDOWS LIVE WRITER DOESN&amp;quot;T USE THIS YET
    &lt;/span&gt;&lt;span style="color: blue"&gt;return true&lt;/span&gt;;
}
[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;metaWeblog.getCategories&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[] getCategories(&lt;span style="color: blue"&gt;string &lt;/span&gt;blogid, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;password)
{
    CheckLoggedIn(username,password);

    &lt;span style="color: blue"&gt;int &lt;/span&gt;intCatCount = 1;
    &lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[] posts = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[intCatCount];

&lt;span style="color: green"&gt;//START LOOP
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;rpcstruct = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;();
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;categoryid&amp;quot;&lt;/span&gt;,&lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;); 
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;Blog category&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;My blog category&amp;quot;&lt;/span&gt;);
    posts[0] = rpcstruct;
&lt;span style="color: green"&gt;//END LOOP

    &lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;posts;
}
[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;metaWeblog.getRecentPosts&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[] getRecentPosts(&lt;span style="color: blue"&gt;string &lt;/span&gt;blogid, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;password, &lt;span style="color: blue"&gt;int &lt;/span&gt;numberOfPosts)
{
    CheckLoggedIn(username, password);
&lt;span style="color: green"&gt;//RETRIEVE YOUR BLOG POSTS AND LOOP THROUGH THE RETURN BELOW
    &lt;/span&gt;&lt;span style="color: blue"&gt;int &lt;/span&gt;intBlogCount = 1;
    &lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[] posts = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;[intBlogCount];
    &lt;span style="color: blue"&gt;int &lt;/span&gt;i = 0;

&lt;span style="color: green"&gt;//Populate structure with posts
//START LOOP

    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;rpcstruct = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;();
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;My Blog Post&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;http://myblog/blog01&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;My blog content&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;pubDate&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;01/01/2009&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;guid&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;0001&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;postid&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;keywords&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;123 123&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;author&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;Doug&amp;quot;&lt;/span&gt;);
    posts[i] = rpcstruct;
&lt;span style="color: green"&gt;//END LOOP
&lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;posts;
}
[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;metaWeblog.getTemplate&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public string &lt;/span&gt;getTemplate(&lt;span style="color: blue"&gt;string &lt;/span&gt;appKey, &lt;span style="color: blue"&gt;string &lt;/span&gt;blogid, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;username, &lt;span style="color: blue"&gt;string &lt;/span&gt;password, &lt;span style="color: blue"&gt;string &lt;/span&gt;templateType)
{
    CheckLoggedIn(username, password);
    &lt;span style="color: green"&gt;// LIVE WRITER DOESNT USE THIS YET
    &lt;/span&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;strTemplate = &lt;span style="color: blue"&gt;string&lt;/span&gt;.Empty;
    &lt;span style="color: blue"&gt;return &lt;/span&gt;strTemplate;
}

[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;metaWeblog.newPost&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public string &lt;/span&gt;newPost(&lt;span style="color: blue"&gt;string &lt;/span&gt;blogid, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;password, &lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;rpcstruct, &lt;span style="color: blue"&gt;bool &lt;/span&gt;publish)
{
    CheckLoggedIn(username, password);
    &lt;span style="color: blue"&gt;string &lt;/span&gt;newBlogID = &lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;string &lt;/span&gt;blogTitle = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;].ToString();
    &lt;span style="color: blue"&gt;string &lt;/span&gt;blogLink = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;].ToString();
    &lt;span style="color: blue"&gt;string &lt;/span&gt;blogContent = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;].ToString();
    &lt;span style="color: blue"&gt;string &lt;/span&gt;blogAuthor = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;author&amp;quot;&lt;/span&gt;].ToString();
    &lt;span style="color: blue"&gt;string&lt;/span&gt;[] blogCategories = (&lt;span style="color: blue"&gt;string&lt;/span&gt;[])rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;categories&amp;quot;&lt;/span&gt;];

    &lt;span style="color: blue"&gt;return &lt;/span&gt;newBlogID;
}

[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;metaWeblog.editPost&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public bool &lt;/span&gt;editPost(&lt;span style="color: blue"&gt;string &lt;/span&gt;postid, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, &lt;span style="color: blue"&gt;string &lt;/span&gt;password, 
    &lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;rpcstruct, &lt;span style="color: blue"&gt;bool &lt;/span&gt;publish)
{
    CheckLoggedIn(username, password);
    &lt;span style="color: blue"&gt;string &lt;/span&gt;blogTitle = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;].ToString();
    &lt;span style="color: blue"&gt;string &lt;/span&gt;blogLink = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;].ToString();
    &lt;span style="color: blue"&gt;string &lt;/span&gt;blogContent = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;].ToString();
    &lt;span style="color: blue"&gt;string &lt;/span&gt;blogAuthor = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;author&amp;quot;&lt;/span&gt;].ToString();
    &lt;span style="color: blue"&gt;string&lt;/span&gt;[] blogCategories = (&lt;span style="color: blue"&gt;string&lt;/span&gt;[])rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;categories&amp;quot;&lt;/span&gt;];

    &lt;span style="color: blue"&gt;return true&lt;/span&gt;;
}

[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;metaWeblog.getPost&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;getPost(&lt;span style="color: blue"&gt;string &lt;/span&gt;postid, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;password)
{
    CheckLoggedIn(username, password);
    &lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;rpcstruct = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;();
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;My blog title&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;http://myblogpostURL.com&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;My blog post content&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;pubDate&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;01/01/2009&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;guid&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;00001&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;postid&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;author&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;Doug&amp;quot;&lt;/span&gt;);
    rpcstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;publish&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;);
    &lt;span style="color: blue"&gt;return &lt;/span&gt;rpcstruct;
}

[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;blogger.deletePost&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public bool &lt;/span&gt;deletePost(&lt;span style="color: blue"&gt;string &lt;/span&gt;appKey, &lt;span style="color: blue"&gt;string &lt;/span&gt;postid, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;password, &lt;span style="color: blue"&gt;bool &lt;/span&gt;publish)
{
    CheckLoggedIn(username, password);
    &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt;DELETE THE POST WITH THE ID 'postid'
    &lt;/span&gt;&lt;span style="color: blue"&gt;return false&lt;/span&gt;;
}

[&lt;span style="color: #2b91af"&gt;XmlRpcMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;metaWeblog.newMediaObject&amp;quot;&lt;/span&gt;)]
&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;newMediaObject(&lt;span style="color: blue"&gt;string &lt;/span&gt;blogid, &lt;span style="color: blue"&gt;string &lt;/span&gt;username, 
    &lt;span style="color: blue"&gt;string &lt;/span&gt;password, &lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;rpcstruct)
{
    CheckLoggedIn(username, password);

    &lt;span style="color: blue"&gt;string &lt;/span&gt;name = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;].ToString(); &lt;span style="color: green"&gt;//file name
    &lt;/span&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;type = rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;].ToString(); &lt;span style="color: green"&gt;//file type
    &lt;/span&gt;&lt;span style="color: blue"&gt;byte&lt;/span&gt;[] media = (&lt;span style="color: blue"&gt;byte&lt;/span&gt;[])rpcstruct[&lt;span style="color: #a31515"&gt;&amp;quot;bits&amp;quot;&lt;/span&gt;];   &lt;span style="color: green"&gt;//file contents
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;FileStream &lt;/span&gt;stream = &lt;span style="color: #2b91af"&gt;File&lt;/span&gt;.Create(name);
    stream.Write(media, 0, media.Length);
    stream.Flush();
    stream.Close();
    stream.Dispose();
    &lt;span style="color: #2b91af"&gt;XmlRpcStruct &lt;/span&gt;rstruct = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRpcStruct&lt;/span&gt;();
    rstruct.Add(&lt;span style="color: #a31515"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;,&lt;span style="color: #a31515"&gt;&amp;quot;/new filename path/&amp;quot;&lt;/span&gt;);
    &lt;span style="color: blue"&gt;return &lt;/span&gt;rstruct;
}
}
}&lt;/pre&gt;

&lt;h3&gt;Additional thoughts&lt;/h3&gt;

&lt;p&gt;To setup your live writer simply point its MetaWebLog API handler URL you have setup above when setting up your blog account.&lt;/p&gt;

&lt;p&gt;You should probably use an SSL website for your web service endpoint to make sure your open text password doesn’t get snooped by l33t script kiddies (you’ve been warned). &lt;/p&gt;

&lt;p&gt;You may want to use soft deletes on your blog simply in case someone gets a hold of you live writer install and gets over excited – the thought that someone can remotely delete your posts can be a dangerous thought in the wrong hands. &lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/xfXb2SWSbRg" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/10/07/adding-windows-live-writer-support-to-your-blog-engine</feedburner:origLink></item><item><title>Sending encrypted e-mail with C#</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/sSZyWNhk_Ig/sending-encrypted-email-with-c</link><description>&lt;p&gt;There are times when the invention that we all call E-mail just doesn’t cut it for sending information securely. It is because of this that in every case where information really needs to be sent securely E-mail is not usually the medium chosen to send it. As most developers know though there are times when you have to bite the unsecure E-mail bullet. I’ll show you a way to solve this conundrum and at the same time probably keep your current e-mail client.&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/padlock_2.gif"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="padlock" border="0" alt="padlock" align="right" src="http://www.diaryofaninja.com/asset/blogimages/padlock_thumb.gif" width="150" height="236" /&gt;&lt;/a&gt; Secure you say!? E-mail is not secure!&lt;/h3&gt;  &lt;p&gt;Not many people know who about the secure capabilities of e-mail, so it may come as a surprise that the method I'm going to show you in most cases will use the same e-mail client you are currently using and requires very little work to setup.&lt;/p&gt;  &lt;p&gt;It is possible to encrypt your message’s contents and send this encrypted blob as an attachment known as an &lt;strong&gt;Alternate View&lt;/strong&gt;. If the destination mail client has a copy of the encryption key it un-encrypts the attachment and displays it as the message itself. &lt;/p&gt;  &lt;p&gt;Pretty neat huh?&lt;/p&gt;  &lt;p&gt;Dot Net supports Personal (X509) Certificates out of the box – and this little baby packs a lot of punch when you want to get things done with secure e-mail. So we’re going to harness this power to make it happen with c#.&lt;/p&gt;  &lt;h3&gt;How to bake a cake&lt;/h3&gt;  &lt;p&gt;Today’s recipe is really very simple and requires only the following ingredients:&lt;/p&gt;  &lt;p&gt;1. A personal SSL certificate&lt;/p&gt;  &lt;p&gt;2. The code i provide below&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Where do i get a personal SSL certificate from? Are they expensive?&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Depending on your knowledge of SSL certificates you may be scratching your head as to what your next step may be. You may have never even heard of personal SSL certificates.&lt;/p&gt;  &lt;p&gt;Luckily for you there is an ever need for simple personal SSL certificates. Furthermore, certain companies have decided that they will provide them for free to try and get you in the door on the more expensive certificates. &lt;/p&gt;  &lt;p&gt;Most serious SSL providers can arrange one for you (you can even install your own certificate authority server if your so inclined). But for this exercise we are going to use the free personal email certificate service from &lt;a href="https://www.thawte.com" target="_blank"&gt;Thwarte&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Thwarte offers free personal certificates at the following URL so simply go sign yourself up and grab one now – its that simple:&lt;/p&gt;  &lt;p&gt;&lt;a title="https://www.thawte.com/secure-email/personal-email-certificates/index.html" href="https://www.thawte.com/secure-email/personal-email-certificates/index.html"&gt;https://www.thawte.com/secure-email/personal-email-certificates/index.html&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Installing the certificate&lt;/h3&gt;  &lt;p&gt;Now that you have your personal certificate, you want to go ahead and install it in your e-mail client. There are different instructions depending on your email client – I'm not going to go into much detail on how to do this as you probably have a different situation/OS/e-mail client than I do.&lt;/p&gt;  &lt;p&gt;What i will do however is provide some information that shows you how to get it working on a few popular Windows clients:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.globalsign.com/support/personal-certificate/per_outlookex.html" target="_blank"&gt;Outlook Express&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.globalsign.com/support/personal-certificate/per_outlook07.html" target="_blank"&gt;Outlook 2007&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If i haven’t listed your client and you want to find out how to “get it done” then maybe you need to make Google your friend. As mentioned that’s sadly not in the scope of this post. &lt;/p&gt;  &lt;p&gt;Onwards and upwards.&lt;/p&gt;  &lt;h3&gt;Adding X509 Certificate support to your app&lt;/h3&gt;  &lt;p&gt;The next thing your going to have to do is add a reference to &lt;strong&gt;System.Security&lt;/strong&gt; in your web app. This is not a common thing to use in a web app, but as this is where the &lt;a href="http://en.wikipedia.org/wiki/Kool-Aid" target="_blank"&gt;Koolade&lt;/a&gt; is flowing from on our little adventure, you’ll have to go do this now. &lt;/p&gt;  &lt;h3&gt;Show me the code&lt;/h3&gt;  &lt;p&gt;So without further adieu…&lt;/p&gt;  &lt;p&gt;The code below is an example of how to do what I've been babbling on about for the past few paragraphs – as i like to lead with examples I'll simply give you the code and you can take it from there :-) &lt;/p&gt;  &lt;p&gt;I’ve added comments to the juicy bits to try and explain what we are doing as we go.&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.IO;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Net.Mail;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Security.Cryptography.X509Certificates;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Text;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Security.Cryptography.Pkcs;

&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SendEncryptedEmail
&lt;/span&gt;{
&lt;span style="color: blue"&gt;public void &lt;/span&gt;SendEmail()
{
    &lt;span style="color: green"&gt;//set my certificate info up
    &lt;/span&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;CertificatePath = &lt;span style="color: #a31515"&gt;&amp;quot;C:\\my_sslcert.p12&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;string &lt;/span&gt;CertificatePassword = &lt;span style="color: #a31515"&gt;&amp;quot;my certificate pass&amp;quot;&lt;/span&gt;;

    &lt;span style="color: blue"&gt;string &lt;/span&gt;MailServer = &lt;span style="color: #a31515"&gt;&amp;quot;mail.mydomain.com&amp;quot;&lt;/span&gt;;

    &lt;span style="color: blue"&gt;string &lt;/span&gt;EmailRecipient = &lt;span style="color: #a31515"&gt;&amp;quot;your@emailaddress.com&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;string &lt;/span&gt;EmailSender = &lt;span style="color: #a31515"&gt;&amp;quot;your@sender.com&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;string &lt;/span&gt;EmailSubject = &lt;span style="color: #a31515"&gt;&amp;quot;My first secure email&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;string &lt;/span&gt;EmailBody = &lt;span style="color: #a31515"&gt;&amp;quot;This is a secure email&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;bool &lt;/span&gt;IsHtmlEmail = &lt;span style="color: blue"&gt;false&lt;/span&gt;;

    &lt;span style="color: green"&gt;//Load the certificate
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;X509Certificate2 &lt;/span&gt;EncryptCert = 
       &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;X509Certificate2&lt;/span&gt;(CertificatePath, CertificatePassword);

    &lt;span style="color: green"&gt;//Build the body into a string
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StringBuilder &lt;/span&gt;Message = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StringBuilder&lt;/span&gt;();
    Message.AppendLine(&lt;span style="color: #a31515"&gt;&amp;quot;Content-Type: text/&amp;quot; &lt;/span&gt;+ 
        ((IsHtmlEmail) ? &lt;span style="color: #a31515"&gt;&amp;quot;html&amp;quot; &lt;/span&gt;: &lt;span style="color: #a31515"&gt;&amp;quot;plain&amp;quot;&lt;/span&gt;) +
        &lt;span style="color: #a31515"&gt;&amp;quot;; charset=\&amp;quot;iso-8859-1\&amp;quot;&amp;quot;&lt;/span&gt;);

    Message.AppendLine(&lt;span style="color: #a31515"&gt;&amp;quot;Content-Transfer-Encoding: 7bit&amp;quot;&lt;/span&gt;);
    Message.AppendLine(EmailBody);

    &lt;span style="color: green"&gt;//Convert the body to bytes
    &lt;/span&gt;&lt;span style="color: blue"&gt;byte&lt;/span&gt;[] BodyBytes = &lt;span style="color: #2b91af"&gt;Encoding&lt;/span&gt;.ASCII.GetBytes(Message.ToString());

    &lt;span style="color: green"&gt;//Build the e-mail body bytes into a secure envelope
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EnvelopedCms &lt;/span&gt;Envelope = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EnvelopedCms&lt;/span&gt;(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ContentInfo&lt;/span&gt;(BodyBytes));
    &lt;span style="color: #2b91af"&gt;CmsRecipient &lt;/span&gt;Recipient = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;CmsRecipient&lt;/span&gt;(
        &lt;span style="color: #2b91af"&gt;SubjectIdentifierType&lt;/span&gt;.IssuerAndSerialNumber, EncryptCert);
    Envelope.Encrypt(Recipient);
    &lt;span style="color: blue"&gt;byte&lt;/span&gt;[] EncryptedBytes = Envelope.Encode();

    &lt;span style="color: green"&gt;//Creat the mail message
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MailMessage &lt;/span&gt;Msg = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MailMessage&lt;/span&gt;();
    Msg.To.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MailAddress&lt;/span&gt;(EmailRecipient));
    Msg.From = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MailAddress&lt;/span&gt;(EmailSender);
    Msg.Subject = EmailSubject;

    &lt;span style="color: green"&gt;//Attach the encrypted body to the email as and ALTERNATE VIEW
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MemoryStream &lt;/span&gt;ms = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt;(EncryptedBytes);
    &lt;span style="color: #2b91af"&gt;AlternateView &lt;/span&gt;av = 
        &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AlternateView&lt;/span&gt;(ms,
        &lt;span style="color: #a31515"&gt;&amp;quot;application/pkcs7-mime; smime-type=signed-data;name=smime.p7m&amp;quot;&lt;/span&gt;);
    Msg.AlternateViews.Add(av);

    &lt;span style="color: #2b91af"&gt;SmtpClient &lt;/span&gt;smtp = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SmtpClient&lt;/span&gt;(MailServer, 25);     
    &lt;span style="color: green"&gt;//send the email                                       
    &lt;/span&gt;smtp.Send(Msg);
}
}&lt;/pre&gt;

&lt;h3&gt;The results&lt;/h3&gt;

&lt;p&gt;Once you’ve got your certificate and pointed the above code at it you should be on your way to sending secure emails using c#.&lt;/p&gt;

&lt;p&gt;Below is an example of a secure e-mail received using the above method in outlook 2007.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inbox View&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/myInbox.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="myInbox" border="0" alt="myInbox" src="http://www.diaryofaninja.com/asset/blogimages/myInbox_thumb.jpg" width="400" height="74" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p class="caption"&gt;Take note of the padlock email icon&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Message View&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/theEmail.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="theEmail" border="0" alt="theEmail" src="http://www.diaryofaninja.com/asset/blogimages/theEmail_thumb.jpg" width="400" height="170" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p class="caption"&gt;Take note of the blue padlock on the right hand side of the header.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/sSZyWNhk_Ig" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/10/02/sending-encrypted-email-with-c</feedburner:origLink></item><item><title>Upgrading Umbraco from 3 to 4 &amp;ndash; Not all smooth sailing</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/abR4IFFljYQ/upgrading-umbraco-from-3-to-4-ndash-not-all-smooth-sailing</link><description>&lt;p&gt;If you have ever had to setup or manage an &lt;a href="http://umbraco.org/" target="_blank"&gt;Umbraco&lt;/a&gt; installation you will know both the pleasure and the occasional pain that it can bring. Umbraco is part of the growing list of &lt;strong&gt;“oober cool”&lt;/strong&gt; up and coming Dot Net CMS that are getting attention in the “get it up quick” world of marketing driven sites in the market place (Ford Australia for example). I recently had to upgrade a clients installation from 3.0.5 to 4.0.2.1 and the story that follows will hopefully help someone in a similar position so that they can revel in the same relief that I do currently.&lt;/p&gt;  &lt;h3&gt;Follow the installation guide (but don’t depend on it)&lt;/h3&gt;  &lt;p&gt;I won’t go through all the steps involved in the upgrade process as the &lt;a href="http://umbraco.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=23321" target="_blank"&gt;Umbraco Codeplex site&lt;/a&gt; (click on upgrade guide) and quite a few blog &lt;a href="http://farmcode.org/post/2009/02/05/Upgrading-to-Umbraco-4.aspx" target="_blank"&gt;entries&lt;/a&gt; detail this – if you are experiencing issues simply upgrading and haven’t looked on Google then this guide should not be your first stop. What appeared to happen to my installation was not covered in any of the usual stuff and the battle that ensued is what i am going to discuss.&lt;/p&gt;  &lt;p&gt;I followed the install guide and it successfully updated my database (partially, but we’ll get to that), my templates to the new master page format and all the files involved to run the new version. The list that follows is my list of issues and each solution.&lt;/p&gt;  &lt;h3&gt;Issue 1: Unable to login to the admin&lt;/h3&gt;  &lt;p&gt;This is an issue that has been flagged very clearly in the install guide and i was aware of but i thought i would mention it as quite a few people repeatedly discuss this in &lt;a href="http://our.umbraco.org/forum" target="_blank"&gt;Umbraco’s Forums&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Umbraco 4’s Membership provider now hashes its passwords for better security, so after upgrading, your old passwords (unhashed) will not match a hashed copy of your entered password. &lt;/p&gt;  &lt;p&gt;There is a really simple fix: &lt;strong&gt;turn clear passwords back on&lt;/strong&gt;. &lt;/p&gt;  &lt;p&gt;Below is a copy of a before and after of my membership provider part of my web.config that does just this:&lt;/p&gt;  &lt;p&gt;Before:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;UmbracoMembershipProvider&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;umbraco.providers.members.UmbracoMembershipProvider&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;enablePasswordRetrieval&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;false&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;enablePasswordReset&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;false&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;requiresQuestionAndAnswer&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;false&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;defaultMemberTypeAlias&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Another Type&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;passwordFormat&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Hashed&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;After&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;UmbracoMembershipProvider&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;umbraco.providers.members.UmbracoMembershipProvider&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;enablePasswordRetrieval&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;false&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;enablePasswordReset&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;false&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;requiresQuestionAndAnswer&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;false&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;defaultMemberTypeAlias&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Another Type&lt;/span&gt;&amp;quot; 
    &lt;span style="color: red"&gt;passwordFormat&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Clear&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;After making the above change you should be ready to rock and roll. Point your browser at the Umbraco site (usually /umbraco/) and you should be all good.&lt;/p&gt;

&lt;h3&gt;Issue 2: After logging in all content does not show&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/UmbracoEmptyContent_2.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="UmbracoEmptyContent" border="0" alt="UmbracoEmptyContent" src="http://www.diaryofaninja.com/asset/blogimages/UmbracoEmptyContent_thumb.gif" width="541" height="196" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The second issue was a perfect example of the feeling &lt;em&gt;“so-close-yet-so-far”, &lt;/em&gt;as my installation’s admin area was now functional and i was logged in. Everything looked pretty and &lt;em&gt;Umbraco-4-ish&lt;/em&gt; and yet all my client’s content was missing. I was starting to think that the upgrade had failed, my database backup from the clients server was corrupt or any number of things. One of the strange things was that if i right clicked on the top node and clicked on &lt;strong&gt;Sort&lt;/strong&gt; all my content was available for sorting.&lt;/p&gt;

&lt;p&gt;After half an hours searching on the big &lt;strong&gt;&lt;a href="http://www.google.com.au" target="_blank"&gt;G&lt;/a&gt;&lt;/strong&gt; i found someone in the Umbraco forums had mentioned that they had fixed this issue by simply &lt;strong&gt;Republishing the whole site&lt;/strong&gt;. I was really excited to have found a solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Until it did nothing…. :(&lt;/strong&gt; 

  &lt;br /&gt;(I’d still try this incase it works for your installation)&lt;/p&gt;

&lt;p&gt;Starting to feel like i was at the beginning of a long journey i started digging around in the Umbraco database to both see if the content was missing, as well as try and figure out what could be done to rectify the situation.&lt;/p&gt;

&lt;p&gt;I soon found that there were no records setting up permissions from my account to view the nodes that the content was stored in. This was going to need some rectification to the database by hand.&lt;/p&gt;

&lt;p&gt;Luckily for me someone had shared this issue - &lt;a href="http://web-garden.co.uk/2008/9/10/upgrading-umbraco-v4-to-the-latest-version.aspx" target="_blank"&gt;David Conlisk from Web garden&lt;/a&gt; (If your living in Umbraco world you should really check out his site) and had received help from an Umbraco solution provider already: Connect Digital. &lt;/p&gt;

&lt;p&gt;David has nicely allowed me to include the SQL below:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: green"&gt;/* Add ActionBrowse as a default permission to all &lt;br /&gt;&lt;/span&gt;&lt;span style="color: green"&gt;user types that have ActionUpdate */
&lt;/span&gt;&lt;span style="color: blue"&gt;UPDATE &lt;/span&gt;umbracoUserType &lt;span style="color: blue"&gt;SET &lt;/span&gt;userTypeDefaultPermissions &lt;span style="color: gray"&gt;= &lt;br /&gt;&lt;/span&gt;              userTypeDefaultPermissions &lt;span style="color: gray"&gt;+ &lt;/span&gt;&lt;span style="color: red"&gt;'F' &lt;/span&gt;&lt;span style="color: blue"&gt;WHERE &lt;br /&gt;&lt;/span&gt;&lt;span style="color: magenta"&gt;              CHARINDEX&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'A'&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;userTypeDefaultPermissions&lt;span style="color: gray"&gt;,&lt;/span&gt;0&lt;span style="color: gray"&gt;) &amp;gt;= &lt;/span&gt;1 &lt;span style="color: gray"&gt;AND &lt;br /&gt;&lt;/span&gt;&lt;span style="color: magenta"&gt;              CHARINDEX&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'F'&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;userTypeDefaultPermissions&lt;span style="color: gray"&gt;,&lt;/span&gt;0&lt;span style="color: gray"&gt;) &amp;lt; &lt;/span&gt;1&lt;span style="color: gray"&gt;;
&lt;/span&gt;&lt;span style="color: green"&gt;/* Add ActionToPublish to all users types that have the alias 'writer'
*/
&lt;/span&gt;&lt;span style="color: blue"&gt;UPDATE &lt;/span&gt;umbracoUserType &lt;span style="color: blue"&gt;SET &lt;/span&gt;userTypeDefaultPermissions &lt;span style="color: gray"&gt;=
&lt;/span&gt;userTypeDefaultPermissions &lt;span style="color: gray"&gt;+ &lt;/span&gt;&lt;span style="color: red"&gt;'H' &lt;/span&gt;&lt;span style="color: blue"&gt;WHERE &lt;/span&gt;userTypeAlias &lt;span style="color: gray"&gt;= &lt;/span&gt;&lt;span style="color: red"&gt;'writer'
&lt;/span&gt;&lt;span style="color: gray"&gt;AND &lt;/span&gt;&lt;span style="color: magenta"&gt;CHARINDEX&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'F'&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;userTypeDefaultPermissions&lt;span style="color: gray"&gt;,&lt;/span&gt;0&lt;span style="color: gray"&gt;) &amp;lt; &lt;/span&gt;1
&lt;span style="color: gray"&gt;;
&lt;/span&gt;&lt;span style="color: green"&gt;/* Add ActionBrowse to all user permissions for nodes that have the
ActionUpdate permission */
&lt;/span&gt;&lt;span style="color: blue"&gt;IF &lt;/span&gt;&lt;span style="color: gray"&gt;NOT EXISTS (&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;permission &lt;span style="color: blue"&gt;FROM &lt;/span&gt;umbracoUser2NodePermission &lt;span style="color: blue"&gt;WHERE
&lt;/span&gt;permission&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'F'&lt;/span&gt;&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;INSERT INTO &lt;/span&gt;umbracoUser2NodePermission &lt;span style="color: gray"&gt;(&lt;/span&gt;userID&lt;span style="color: gray"&gt;, &lt;/span&gt;nodeId&lt;span style="color: gray"&gt;, &lt;/span&gt;permission&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;userID&lt;span style="color: gray"&gt;, &lt;/span&gt;nodeId&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'F' &lt;/span&gt;&lt;span style="color: blue"&gt;FROM &lt;/span&gt;umbracoUser2NodePermission &lt;span style="color: blue"&gt;WHERE
&lt;/span&gt;permission&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'A'
&lt;/span&gt;&lt;span style="color: gray"&gt;;
&lt;/span&gt;&lt;span style="color: green"&gt;/* Add ActionToPublish permissions to all nodes for users that are of
type 'writer' */
&lt;/span&gt;&lt;span style="color: blue"&gt;IF &lt;/span&gt;&lt;span style="color: gray"&gt;NOT EXISTS (&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;permission &lt;span style="color: blue"&gt;FROM &lt;/span&gt;umbracoUser2NodePermission &lt;span style="color: blue"&gt;WHERE
&lt;/span&gt;permission&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'H'&lt;/span&gt;&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;INSERT INTO &lt;/span&gt;umbracoUser2NodePermission &lt;span style="color: gray"&gt;(&lt;/span&gt;userID&lt;span style="color: gray"&gt;, &lt;/span&gt;nodeId&lt;span style="color: gray"&gt;, &lt;/span&gt;permission&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT DISTINCT &lt;/span&gt;userID&lt;span style="color: gray"&gt;, &lt;/span&gt;nodeId&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'H' &lt;/span&gt;&lt;span style="color: blue"&gt;FROM &lt;/span&gt;umbracoUser2NodePermission
&lt;span style="color: blue"&gt;WHERE &lt;/span&gt;userId &lt;span style="color: gray"&gt;IN
(&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;umbracoUser&lt;span style="color: gray"&gt;.&lt;/span&gt;id &lt;span style="color: blue"&gt;FROM &lt;/span&gt;umbracoUserType &lt;span style="color: gray"&gt;INNER JOIN &lt;/span&gt;umbracoUser &lt;span style="color: blue"&gt;ON
&lt;/span&gt;umbracoUserType&lt;span style="color: gray"&gt;.&lt;/span&gt;id &lt;span style="color: gray"&gt;= &lt;/span&gt;umbracoUser&lt;span style="color: gray"&gt;.&lt;/span&gt;userType &lt;span style="color: blue"&gt;WHERE
&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;umbracoUserType&lt;span style="color: gray"&gt;.&lt;/span&gt;userTypeAlias &lt;span style="color: gray"&gt;= &lt;/span&gt;&lt;span style="color: red"&gt;'writer'&lt;/span&gt;&lt;span style="color: gray"&gt;))
;
&lt;/span&gt;&lt;span style="color: green"&gt;/* Add the contentRecycleBin tree type */
&lt;/span&gt;&lt;span style="color: blue"&gt;IF &lt;/span&gt;&lt;span style="color: gray"&gt;NOT EXISTS (&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;treeAlias &lt;span style="color: blue"&gt;FROM &lt;/span&gt;umbracoAppTree &lt;span style="color: blue"&gt;WHERE
&lt;/span&gt;treeAlias&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'contentRecycleBin'&lt;/span&gt;&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;INSERT INTO &lt;/span&gt;umbracoAppTree &lt;span style="color: gray"&gt;(&lt;/span&gt;treeSilent&lt;span style="color: gray"&gt;, &lt;/span&gt;treeInitialize&lt;span style="color: gray"&gt;, &lt;/span&gt;treeSortOrder&lt;span style="color: gray"&gt;,
&lt;/span&gt;appAlias&lt;span style="color: gray"&gt;, &lt;/span&gt;treeAlias&lt;span style="color: gray"&gt;, &lt;/span&gt;treeTitle&lt;span style="color: gray"&gt;, &lt;/span&gt;treeIconClosed&lt;span style="color: gray"&gt;, &lt;/span&gt;treeIconOpen&lt;span style="color: gray"&gt;,
&lt;/span&gt;treeHandlerAssembly&lt;span style="color: gray"&gt;, &lt;/span&gt;treeHandlerType&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;0&lt;span style="color: gray"&gt;, &lt;/span&gt;0&lt;span style="color: gray"&gt;, &lt;/span&gt;0&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'content'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'contentRecycleBin'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'RecycleBin'&lt;/span&gt;&lt;span style="color: gray"&gt;,
&lt;/span&gt;&lt;span style="color: red"&gt;'folder.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'folder_o.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'umbraco'&lt;/span&gt;&lt;span style="color: gray"&gt;,
&lt;/span&gt;&lt;span style="color: red"&gt;'cms.presentation.Trees.ContentRecycleBin'&lt;/span&gt;&lt;span style="color: gray"&gt;)
;
&lt;/span&gt;&lt;span style="color: green"&gt;/* Add the UserType tree type */
&lt;/span&gt;&lt;span style="color: blue"&gt;IF &lt;/span&gt;&lt;span style="color: gray"&gt;NOT EXISTS (&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;treeAlias &lt;span style="color: blue"&gt;FROM &lt;/span&gt;umbracoAppTree &lt;span style="color: blue"&gt;WHERE
&lt;/span&gt;treeAlias&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'userTypes'&lt;/span&gt;&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;INSERT INTO &lt;/span&gt;umbracoAppTree &lt;span style="color: gray"&gt;(&lt;/span&gt;treeSilent&lt;span style="color: gray"&gt;, &lt;/span&gt;treeInitialize&lt;span style="color: gray"&gt;, &lt;/span&gt;treeSortOrder&lt;span style="color: gray"&gt;,
&lt;/span&gt;appAlias&lt;span style="color: gray"&gt;, &lt;/span&gt;treeAlias&lt;span style="color: gray"&gt;, &lt;/span&gt;treeTitle&lt;span style="color: gray"&gt;, &lt;/span&gt;treeIconClosed&lt;span style="color: gray"&gt;, &lt;/span&gt;treeIconOpen&lt;span style="color: gray"&gt;,
&lt;/span&gt;treeHandlerAssembly&lt;span style="color: gray"&gt;, &lt;/span&gt;treeHandlerType&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;0&lt;span style="color: gray"&gt;, &lt;/span&gt;1&lt;span style="color: gray"&gt;, &lt;/span&gt;1&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'users'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'userTypes'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'User Types'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'folder.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;,
&lt;/span&gt;&lt;span style="color: red"&gt;'folder_o.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'umbraco'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'cms.presentation.Trees.UserTypes'&lt;/span&gt;&lt;span style="color: gray"&gt;)
;
&lt;/span&gt;&lt;span style="color: green"&gt;/* Add the User Permission tree type */
&lt;/span&gt;&lt;span style="color: blue"&gt;IF &lt;/span&gt;&lt;span style="color: gray"&gt;NOT EXISTS (&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;treeAlias &lt;span style="color: blue"&gt;FROM &lt;/span&gt;umbracoAppTree &lt;span style="color: blue"&gt;WHERE
&lt;/span&gt;treeAlias&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'userPermissions'&lt;/span&gt;&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;INSERT INTO &lt;/span&gt;umbracoAppTree &lt;span style="color: gray"&gt;(&lt;/span&gt;treeSilent&lt;span style="color: gray"&gt;, &lt;/span&gt;treeInitialize&lt;span style="color: gray"&gt;, &lt;/span&gt;treeSortOrder&lt;span style="color: gray"&gt;,
&lt;/span&gt;appAlias&lt;span style="color: gray"&gt;, &lt;/span&gt;treeAlias&lt;span style="color: gray"&gt;, &lt;/span&gt;treeTitle&lt;span style="color: gray"&gt;, &lt;/span&gt;treeIconClosed&lt;span style="color: gray"&gt;, &lt;/span&gt;treeIconOpen&lt;span style="color: gray"&gt;,
&lt;/span&gt;treeHandlerAssembly&lt;span style="color: gray"&gt;, &lt;/span&gt;treeHandlerType&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;0&lt;span style="color: gray"&gt;, &lt;/span&gt;1&lt;span style="color: gray"&gt;, &lt;/span&gt;2&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'users'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'userPermissions'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'User Permissions'&lt;/span&gt;&lt;span style="color: gray"&gt;,
&lt;/span&gt;&lt;span style="color: red"&gt;'folder.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'folder_o.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;'umbraco'&lt;/span&gt;&lt;span style="color: gray"&gt;,
&lt;/span&gt;&lt;span style="color: red"&gt;'cms.presentation.Trees.UserPermissions'&lt;/span&gt;&lt;span style="color: gray"&gt;)
;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;After running the above SQL against my database, republishing the entire site through the admin and then restarting the app to clear Umbraco’s cache i still had no content!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE: After running the upgrade a second time once getting everything working i now know that you still have to run the above regardless&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I needed to look elsewhere. This is when i came across a part of the web.config (by pure fluke) that looks like below:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;key&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;umbracoHideTopLevelNodeFromPath&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;true&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;After setting this to false and restarting the site i was looking at all the content nodes.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Woohoo!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Issue 3: Media management not functioning and badly named&lt;/h3&gt;

&lt;p&gt;Now that i had content working i was over the moon. Thought i was home and hosed. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I was wrong.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All my media was showing up fine but i wanted to be a good developer and test it. After quickly testing that i could upload a new image and delete it to simply make sure that, what i thought, may be any potential file permission issues i hit another stop on our journey. &lt;/p&gt;

&lt;p&gt;It appeared that any action on the sites media would cause a Dot Net error. It was then that i realised that the whole section was called &lt;strong&gt;Medier&lt;/strong&gt;, and after reviewing the stack track realised that it was trying to talk to a folder called &lt;strong&gt;medier&lt;/strong&gt; as well. &lt;/p&gt;

&lt;p&gt;How odd…&lt;/p&gt;

&lt;p&gt;A quick search found that someone else had also &lt;a href="http://forum.umbraco.org/yaf_postst6838_Upgrade-site-from-umbraco-305-to-umbraco-4.aspx" target="_blank"&gt;had an issue with this&lt;/a&gt; on an older version upgrade – maybe i shared the same issue. What i didn’t know is that Medier is how they spell it in Denmark.&lt;/p&gt;

&lt;p&gt;They posted a bit of SQL that would change the node information to list it properly as &lt;strong&gt;Media.&lt;/strong&gt; I ran this script (listed on the above post) however it was not enough as it did not set the &lt;strong&gt;treeAlias &lt;/strong&gt;(folder name) property as well. &lt;/p&gt;

&lt;p&gt;A simple modification to this script is shown below that will reset both properties:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;update &lt;/span&gt;umbracoAppTree &lt;br /&gt;&lt;span style="color: blue"&gt;set &lt;/span&gt;treeTitle&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'Media'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;treeAlias&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'media'  &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;where &lt;/span&gt;treeTitle&lt;span style="color: gray"&gt;=&lt;/span&gt;&lt;span style="color: red"&gt;'Medier'&lt;/span&gt;&lt;span style="color: gray"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Another quick restart of the Umbraco cache and i was away… :) Media worked.&lt;/p&gt;

&lt;h3&gt;Issue 4: Adding package support now that you’ve upgraded&lt;/h3&gt;

&lt;p&gt;My new Umbraco 4 installation was humming along and i was a happy developer. The only other thing that was a quick tweak was changing the data type &lt;strong&gt;RichTextBox &lt;/strong&gt;to use the new version of TinyMCE installed with Umbraco 4. This was easy as a nice little JavaScript alert informed me what i should do to fix it (how cool is that – great work guys).&lt;/p&gt;

&lt;p&gt;It was then that the next stage of my clients upgrade brought about the attention of a missing feature in my new Umbraco 4 installation. I was attempting to install a plug-in for Umbraco called &lt;a href="http://www.nibble.be/?p=57" target="_blank"&gt;Umbraco Blog&lt;/a&gt; when i quickly realised: I was missing the new glorious packaging system that everyone over at Umbraco is raving about.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Here we go again!…&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So obviously i was missing part of the upgrade. Why? I had started to think that some of the issues i was having was because i had not upgraded to mid-point version that had included a lot of other things included, and that these things weren’t added to the upgrade to 4.0.&lt;/p&gt;

&lt;p&gt;I then i remembered something from &lt;a href="http://web-garden.co.uk/2008/9/10/upgrading-umbraco-v4-to-the-latest-version.aspx" target="_blank"&gt;David Conlisk’s post &lt;/a&gt;that mentioned looking in the &lt;strong&gt;total.sql&lt;/strong&gt; for Umbraco over at CodePlex – this can be accessed &lt;a href="http://umbraco.codeplex.com/SourceControl/changeset/view/39999#448991" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After doing a quick &lt;em&gt;find &lt;/em&gt;in my browswer i came across two &lt;strong&gt;very interesting&lt;/strong&gt; lines shown below.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: green"&gt;/* 3.1 SQL changes */
&lt;/span&gt;&lt;span style="color: blue"&gt;INSERT INTO &lt;/span&gt;[umbracoAppTree] &lt;span style="color: gray"&gt;(&lt;/span&gt;[appAlias]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeAlias]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeSilent]&lt;span style="color: gray"&gt;, 
&lt;/span&gt;[treeInitialize]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeSortOrder]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeTitle]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeIconClosed]&lt;span style="color: gray"&gt;, 
&lt;/span&gt;[treeIconOpen]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeHandlerAssembly]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeHandlerType]&lt;span style="color: gray"&gt;) 
&lt;/span&gt;&lt;span style="color: blue"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;N&lt;span style="color: red"&gt;'developer'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'packager'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;0&lt;span style="color: gray"&gt;, &lt;/span&gt;1&lt;span style="color: gray"&gt;, &lt;/span&gt;3&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'Packages'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'folder.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;/span&gt;N&lt;span style="color: red"&gt;'folder_o.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'umbraco'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'loadPackager'&lt;/span&gt;&lt;span style="color: gray"&gt;);

&lt;/span&gt;&lt;span style="color: blue"&gt;INSERT INTO &lt;/span&gt;[umbracoAppTree] &lt;span style="color: gray"&gt;(&lt;/span&gt;[appAlias]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeAlias]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeSilent]&lt;span style="color: gray"&gt;, 
&lt;/span&gt;[treeInitialize]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeSortOrder]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeTitle]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeIconClosed]&lt;span style="color: gray"&gt;, 
&lt;/span&gt;[treeIconOpen]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeHandlerAssembly]&lt;span style="color: gray"&gt;, &lt;/span&gt;[treeHandlerType]&lt;span style="color: gray"&gt;) 
&lt;/span&gt;&lt;span style="color: blue"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;N&lt;span style="color: red"&gt;'developer'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'packagerPackages'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;0&lt;span style="color: gray"&gt;, &lt;/span&gt;0&lt;span style="color: gray"&gt;, &lt;/span&gt;1&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'Packager Packages'&lt;/span&gt;&lt;span style="color: gray"&gt;, 
&lt;/span&gt;N&lt;span style="color: red"&gt;'folder.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'folder_o.gif'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'umbraco'&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;N&lt;span style="color: red"&gt;'loadPackages'&lt;/span&gt;&lt;span style="color: gray"&gt;);&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;After running these lines against my Umbraco DB I was done. It worked!&lt;/p&gt;

&lt;p&gt;Happy days. Everything is now working and I live on to fight another day.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/abR4IFFljYQ" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/30/upgrading-umbraco-from-3-to-4-ndash-not-all-smooth-sailing</feedburner:origLink></item><item><title>Disconnecting users from a MSSQL database using SQL script</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/e56vX265mn8/disconnecting-users-from-a-mssql-database-using-sql-script</link><description>&lt;p&gt;There are many times when there can be a requirement to disconnect users from your Microsoft SQL database. Sometimes you can have bad code keeping connections alive that shouldn’t be, other times your simply want to restore a backup or do something that requires no users to be using the database. Reasons aside, I’ll show you some simple SQL to make it happen.&lt;/p&gt;  &lt;p&gt;My example code if used in full will also take your database offline. The reason for this is the fact that i usually use this if i have to restore a database, and taking it offline stops more users hitting it while I’m trying to do this. &lt;/p&gt;  &lt;h3&gt;Are you sure you want to do this?&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;If I’m going to be doing any restorations or database admin I’m not going to do it on a live database… I think your both inexperienced AND crazy!&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Some of you may be thinking that the idea behind this is all wrong. If something like this needs to be done, you should be solving the issues such as users running queries with other solutions.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Sometimes this is not possible.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Not all my clients use dedicated environments with multiple database servers and a failover cluster etc. Sometimes its sitting on a shitty shared webhost that runs many other sites off the same SQL database, and you have to make changes during off peak times in a quick and dirty fashion.&lt;/p&gt;  &lt;p&gt;This script is for &lt;strong&gt;those&lt;/strong&gt; times.&lt;/p&gt;  &lt;p&gt;If you don’t wish to take the database offline afterwards simply remove the second part as commented below.&lt;/p&gt;  &lt;p&gt;Enjoy:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: green"&gt;-- use the master database
&lt;/span&gt;&lt;span style="color: blue"&gt;USE master
&lt;/span&gt;go
&lt;span style="color: blue"&gt;DECLARE &lt;/span&gt;@DatabaseName &lt;span style="color: blue"&gt;varchar&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;30&lt;span style="color: gray"&gt;), 
    &lt;/span&gt;@ServerProcessID &lt;span style="color: blue"&gt;varchar&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;10&lt;span style="color: gray"&gt;), 
    &lt;/span&gt;@StartTime &lt;span style="color: blue"&gt;datetime

&lt;/span&gt;&lt;span style="color: green"&gt;-- Set our database name to my_database (change this to your db)
&lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;@StartTime &lt;span style="color: gray"&gt;= &lt;/span&gt;&lt;span style="color: blue"&gt;current_timestamp&lt;/span&gt;&lt;span style="color: gray"&gt;, 
    &lt;/span&gt;@DatabaseName &lt;span style="color: gray"&gt;= &lt;/span&gt;&lt;span style="color: red"&gt;'my_database'

&lt;/span&gt;&lt;span style="color: green"&gt;-- Timeout after 3 minutes
&lt;/span&gt;&lt;span style="color: blue"&gt;while&lt;/span&gt;&lt;span style="color: gray"&gt;(exists(&lt;/span&gt;&lt;span style="color: blue"&gt;Select &lt;/span&gt;&lt;span style="color: gray"&gt;* &lt;/span&gt;&lt;span style="color: blue"&gt;FROM &lt;/span&gt;sysprocesses 
            &lt;span style="color: blue"&gt;WHERE dbid &lt;/span&gt;&lt;span style="color: gray"&gt;= &lt;/span&gt;&lt;span style="color: magenta"&gt;db_id&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@DatabaseName&lt;span style="color: gray"&gt;)) AND
            &lt;/span&gt;&lt;span style="color: magenta"&gt;datediff&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;mi&lt;span style="color: gray"&gt;, &lt;/span&gt;@StartTime&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: blue"&gt;current_timestamp&lt;/span&gt;&lt;span style="color: gray"&gt;) &amp;lt; &lt;/span&gt;3&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;begin
        DECLARE &lt;/span&gt;spids &lt;span style="color: blue"&gt;CURSOR FOR
            SELECT &lt;/span&gt;&lt;span style="color: magenta"&gt;convert&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: blue"&gt;varchar&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;spid&lt;span style="color: gray"&gt;) &lt;/span&gt;&lt;span style="color: blue"&gt;FROM &lt;/span&gt;sysprocesses
                &lt;span style="color: blue"&gt;WHERE dbid &lt;/span&gt;&lt;span style="color: gray"&gt;= &lt;/span&gt;&lt;span style="color: magenta"&gt;db_id&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@DatabaseName&lt;span style="color: gray"&gt;)
        &lt;/span&gt;&lt;span style="color: blue"&gt;OPEN &lt;/span&gt;spids
        &lt;span style="color: blue"&gt;while&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;1&lt;span style="color: gray"&gt;=&lt;/span&gt;1&lt;span style="color: gray"&gt;)
        &lt;/span&gt;&lt;span style="color: blue"&gt;BEGIN
            FETCH &lt;/span&gt;spids &lt;span style="color: blue"&gt;INTO &lt;/span&gt;@ServerProcessID
            &lt;span style="color: blue"&gt;IF &lt;/span&gt;&lt;span style="color: magenta"&gt;@@fetch_status &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt; &lt;/span&gt;0 &lt;span style="color: blue"&gt;BREAK
            exec&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;'kill ' &lt;/span&gt;&lt;span style="color: gray"&gt;+ &lt;/span&gt;@ServerProcessID&lt;span style="color: gray"&gt;)
        &lt;/span&gt;&lt;span style="color: blue"&gt;END
        DEALLOCATE &lt;/span&gt;spids
&lt;span style="color: blue"&gt;end

&lt;/span&gt;&lt;span style="color: green"&gt;-- take the database offline so that we can do our backup
&lt;/span&gt;&lt;span style="color: blue"&gt;IF &lt;/span&gt;&lt;span style="color: gray"&gt;NOT exists(&lt;/span&gt;&lt;span style="color: blue"&gt;Select &lt;/span&gt;&lt;span style="color: gray"&gt;* &lt;/span&gt;&lt;span style="color: blue"&gt;FROM &lt;/span&gt;sysprocesses 
        &lt;span style="color: blue"&gt;WHERE dbid &lt;/span&gt;&lt;span style="color: gray"&gt;= &lt;/span&gt;&lt;span style="color: magenta"&gt;db_id&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@DatabaseName&lt;span style="color: gray"&gt;))
            &lt;/span&gt;&lt;span style="color: blue"&gt;EXEC &lt;/span&gt;&lt;span style="color: maroon"&gt;sp_dboption &lt;/span&gt;@DatabaseName&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: blue"&gt;offline&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;true
&lt;span style="color: blue"&gt;else
    begin
        PRINT 
        &lt;/span&gt;&lt;span style="color: red"&gt;'The following server processes are still using '&lt;/span&gt;&lt;span style="color: gray"&gt;+ &lt;/span&gt;@DatabaseName &lt;span style="color: gray"&gt;+&lt;/span&gt;&lt;span style="color: red"&gt;':'
        &lt;/span&gt;&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;spid&lt;span style="color: gray"&gt;, &lt;/span&gt;cmd&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: blue"&gt;status&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;last_batch&lt;span style="color: gray"&gt;, 
                &lt;/span&gt;open_tran&lt;span style="color: gray"&gt;, &lt;/span&gt;&lt;span style="color: magenta"&gt;program_name&lt;/span&gt;&lt;span style="color: gray"&gt;, &lt;/span&gt;hostname
        &lt;span style="color: blue"&gt;FROM &lt;/span&gt;sysprocesses
        &lt;span style="color: blue"&gt;WHERE dbid &lt;/span&gt;&lt;span style="color: gray"&gt;= &lt;/span&gt;&lt;span style="color: magenta"&gt;db_id&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;@DatabaseName&lt;span style="color: gray"&gt;)
&lt;/span&gt;&lt;span style="color: blue"&gt;end
&lt;/span&gt;go&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/e56vX265mn8" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/28/disconnecting-users-from-a-mssql-database-using-sql-script</feedburner:origLink></item><item><title>Forcing ASP.Net to use a Proxy to make requests</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/F_AI_tXhauM/forcing-aspnet-to-use-a-proxy-to-make-requests</link><description>&lt;p&gt;This is a quick one today. I was recently working with a web application that runs a spider to index content on a bunch of intranet sites. The client was a large company with a very security conscious IT team, that had locked down all intranet access from the web server server in question. Luckily Dot Net supports proxies in a loving fashion, and I'll show you how.&lt;/p&gt;  &lt;p&gt;As i just mentioned ASP.Net supports using a proxy for its calls out of the box and this is set very simply in the web.config’s &lt;strong&gt;&amp;lt;system.net&amp;gt; &lt;/strong&gt;section. The great thing is it also allows you to exclude some URL’s from using it just like you would in your internet settings on your desktop – even more powerfully it allows these rules to be set using RegEx! How cool.&lt;/p&gt;  &lt;p&gt;The section definition is listed on MSDN &lt;a href="http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx" target="_blank"&gt;here&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;I have reproduced it below for your pleasure.&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.net&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;defaultProxy&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;!-- &lt;/span&gt;&lt;span style="color: green"&gt;add your proxy address etc &lt;/span&gt;&lt;span style="color: blue"&gt;--&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;proxy
              &lt;/span&gt;&lt;span style="color: red"&gt;proxyaddress&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;http://192.168.0.1:8080&lt;/span&gt;&amp;quot;
              &lt;span style="color: red"&gt;bypassonlocal&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;true&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
        &amp;lt;!-- &lt;/span&gt;&lt;span style="color: green"&gt;add you bypass urls or Regex's for them below &lt;/span&gt;&lt;span style="color: blue"&gt;--&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;bypasslist&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;address&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;[a-z]+\.diaryofaninja\.com&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;bypasslist&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;defaultProxy&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.net&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/F_AI_tXhauM" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/28/forcing-aspnet-to-use-a-proxy-to-make-requests</feedburner:origLink></item><item><title>Running large MSSQL scripts &amp;amp;  resulting memory errors</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/yju-cXiuIEA/running-large-mssql-scripts-amp--resulting-memory-errors</link><description>&lt;p&gt;Today i was battling in the trenches while trying to fix a deployment issue on a foreign webhost with a support team that had a lead time of 3 days on a support ticket when i came across a very annoying issue. While trying to import a large MSSQL script (140mb) i was having a repeated dual to the death with the error &lt;em&gt;&lt;strong&gt;“701 Insufficient Memory”&lt;/strong&gt;&lt;/em&gt; and his evil twin (kind of like the white dreadlock guys in the Matrix) - &lt;em&gt;&lt;strong&gt;“System.OutOfMemoryException”&lt;/strong&gt;&lt;/em&gt; in SQL management studio. But never fear, there is a solution, and its really simple.&lt;/p&gt;  &lt;h3&gt;A bit of background&lt;/h3&gt;  &lt;p&gt;One of the greatest free tools to come from Microsoft in the last couple of years in my opinion is the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=56E5B1C5-BF17-42E0-A410-371A838E570A&amp;amp;displaylang=en" target="_blank"&gt;Database Publishing Wizard&lt;/a&gt;. It generates a single .sql script for your entire database – schema &lt;strong&gt;and&lt;/strong&gt; data together. This is a god send, as quite often when working with a non-dedicated server you can have very limited access to the database itself (sometimes just a web interface) and this allows you to run one script command and you on your way – too easy. &lt;/p&gt;  &lt;p&gt;Usually you do this when you deploy the first time, and the database is quite small in size so its not an issue – but what if your using it as a way to bring the data back or copy it between two sites. This seems silly but as many of you may know that sometimes bad things happen to good people – this was one of these days.&lt;/p&gt;  &lt;h3&gt;Attempt #1 – SQL Management Studio&lt;/h3&gt;  &lt;p&gt;Some of you DBA SQL Sensei's out there will be laughing that i even tried – as this is something I've not done on MS SQL before i didn’t know the rules of the game. I found out the hard way.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/SqlScriptErrorManagementStudio_2.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SqlScriptErrorManagementStudio" border="0" alt="SqlScriptErrorManagementStudio" src="http://www.diaryofaninja.com/asset/blogimages/SqlScriptErrorManagementStudio_thumb.gif" width="400" height="101" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="caption"&gt;Exception of type ‘System.OutOfMemoryException’ was thrown. (mscorlib)&lt;/p&gt;  &lt;p&gt;As you can see from the above image, SQL Management Studio didn’t feel like playing ball on this.&amp;#160; A quick Google and it was very clear that i was not the only one having this issue, not many people had answers.&lt;/p&gt;  &lt;p&gt;However saddened i may have been by this, onwards and upwards.&lt;/p&gt;  &lt;h3&gt;Attempt #2 – SQL Server Agent Package&lt;/h3&gt;  &lt;p&gt;So not to be beaten down i thought i may be able to process this as a job with the SQL Server Agent and let it do the job for me. I thought that this was more of a transaction way of doing things and that i wouldn’t run into any memory errors there – surely people run large SQL agent jobs all the time.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/SqlScriptErrorManagementStudio_2.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SqlScriptErrorManagementStudio" border="0" alt="SqlScriptErrorManagementStudio" src="http://www.diaryofaninja.com/asset/blogimages/SqlScriptErrorManagementStudio_thumb.gif" width="400" height="101" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="caption"&gt;Exception of type ‘System.OutOfMemoryException’ was thrown. (mscorlib)&lt;/p&gt; Exactly the same error – no change at all. What a let down. I was starting to get quite frustrated, as although in this blog post i have skipped from one to the other i actually had tried quite a few varieties of the above two attempts to no avail.   &lt;p&gt;As i was on a deadline to deliver this i had to keep moving.&lt;/p&gt;  &lt;h3&gt;Attempt #3 – C30 Simple SQL Bulk Copy&lt;/h3&gt;  &lt;p&gt;Simple SQL Bulk Copy is one of those utilities that just does what you want when nothing else will. The known issues with SSIS packages not keeping auto-increment ID’s when it does exports are a things of the past. This utility is the &lt;a href="http://www.phrases.org.uk/meanings/knight-in-shining-armour.html" target="_blank"&gt;Knight in shining armour&lt;/a&gt; that you were staying up late at night waiting for.&lt;/p&gt;  &lt;p&gt;While i cannot talk highly enough of this utility it doesn’t do views and functions, so it was copying everything but these things and showing an error while copying them (FYI: it will still keep copying everything else so not all will be lost if you have a use for it). &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;AAAARRRGGHHH!&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;The solution: SQLCMD.EXE&lt;/h3&gt;  &lt;p&gt;As most l33t h4x0rs will tell you there is no place like command prompt, terminal or ssh session. Usually if you know the syntax you can do more with less and a lot of the time in a more stable environment.&lt;/p&gt;  &lt;p&gt;So I'll keep it really simple: &lt;strong&gt;SQLCMD&lt;/strong&gt; is your new friend. It will process the script one line at a time and kick through it bit by bit – this is a lot slower than any of the other forms of importing but hey &lt;a href="http://en.wiktionary.org/wiki/Rome_wasn%27t_built_in_a_day" target="_blank"&gt;Rome wasn’t built in a day&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Simply use the syntax below and you should be on your way:&lt;/p&gt;  &lt;pre class="code"&gt;sqlcmd -S YOURSQLSERVER\INSTANCENAME -i &amp;quot;C:\Your Script.sql”&lt;/pre&gt;

&lt;p&gt;A special note should be made that my first try of the above failed with a &lt;strong&gt;&lt;em&gt;Error 701 – out of memory&lt;/em&gt;&lt;/strong&gt; error. Opening my large script seemed to really mess with Windows XP’s memory and it wasn’t able to properly clear it. After a quick reboot the above worked a treat.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/yju-cXiuIEA" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/25/running-large-mssql-scripts-amp--resulting-memory-errors</feedburner:origLink></item><item><title>Google Chrome Frame - Chrome comes to IE</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/Zpoa6tlnpeQ/google-chrome-frame--chrome-comes-to-ie</link><description>&lt;p&gt;If you haven’ heard yet there is a new browser in town. Like a mutant cyborg from the future built with used parts from the past the “IE-Chrome” browser has &lt;a href="http://googlecode.blogspot.com/2009/09/introducing-google-chrome-frame.html"&gt;leapt&lt;/a&gt; to life. So there has been much talk back and forth over the past day in regards to what this will do for the old browser IE 6 that is the bane of most peoples existences in the development world.&lt;/p&gt;  &lt;p&gt;Packaged as a plug-in for Internet Explorer, Chrome Frame brings the partial rendering engine and JavaScript engine of &lt;a href="http://www.google.com/chrome" target="_blank"&gt;Google Chrome&lt;/a&gt; &lt;em&gt;inside&lt;/em&gt; Internet Explorer. Mainly this adds Chrome’s JavaScript engine and support for HTML 5 – what this leads to in future, we’ll have to wait and see.&lt;/p&gt;  &lt;p&gt;So if your keen to try it out on your dated Internet Explorer installation, then why not give it a try – simply head over to &lt;a title="http://code.google.com/chrome/chromeframe/" href="http://code.google.com/chrome/chromeframe/"&gt;http://code.google.com/chrome/chromeframe/&lt;/a&gt; and grab yourself the plug-in.&lt;/p&gt;  &lt;h3&gt;Why Bother?&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;“… Why bother – Everyone should just upgrade to Firefox…”&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This release from Google has set tongues wagging both for it and against it. Some question whether this may prolong the never ending battle for developers that is known as &lt;strong&gt;IE 6&lt;/strong&gt; and prolong its life in enterprise environments where upgrades have happened at snails pace. &lt;/p&gt;  &lt;p&gt;Others think it will be great to allow the suffering users users (poor souls?) access to the promise land. Your take on this i think will really depend on &lt;strong&gt;what your use your browser for&lt;/strong&gt;, &lt;strong&gt;if you are not using an alternative already&lt;/strong&gt; and if &lt;strong&gt;your involved in the web development&lt;/strong&gt; at large. I’m under the understanding that Google has released this to help with uptake of its new service Wave, which should be coming to a browser near you soon.&lt;/p&gt;  &lt;p&gt;One thing that you should note right away is that Chrome Frame will only fire its rendering goodies if it has a special tag in the page. If this tag is not there, then you’ll be looking through your IE goggles still.&amp;#160; This is good in some ways bad in others (why not have it turned on by default?), but as i mentioned above, this probably leads to being a main usage case for Google’s services in the future. &lt;/p&gt;  &lt;pre class="code"&gt;&amp;lt;meta http-equiv=&amp;quot;X-UA-Compatible&amp;quot; content=&amp;quot;chrome=1&amp;quot;&amp;gt;&lt;/pre&gt;

&lt;p&gt;There's another way to forcibly test a page, though, and that's by including &amp;quot;cf:&amp;quot; in front of the URL. We used this for our tests. &lt;/p&gt;

&lt;pre class="code"&gt;Example: cf:http://www.diaryofaninja.com&lt;/pre&gt;

&lt;h3&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/InternetExplorer8Info_6.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="InternetExplorer8Info" border="0" alt="InternetExplorer8Info" align="right" src="http://www.diaryofaninja.com/asset/blogimages/InternetExplorer8Info_thumb_2.gif" width="262" height="246" /&gt;&lt;/a&gt;Quick look at my current setup&lt;/h3&gt;

&lt;p&gt;So I thought lets install it and give it a try. &lt;/p&gt;

&lt;p&gt;Sadly (only for the purposes of this test) i have Internet Explorer 8 installed not IE 6 although as the plug-in is designed for all Internet Explorer installations i can still install and use it. &lt;/p&gt;

&lt;p&gt;I use Firefox almost exclusively for everything but verifying things work in IE (I'm a very lucky back-end developer and my company employs many HTML gunslingers to make sure things still look good for me… how &lt;strong&gt;la-dee-da&lt;/strong&gt; do I feel).&lt;/p&gt;

&lt;p&gt;The major thing that Chrome is good at (and i think what the folks at Google want the new plug-in used for) is processing JavaScript really fast, so I’m going to run the &lt;a href="http://www2.webkit.org/perf/sunspider-0.9/sunspider.html" target="_blank"&gt;SunSpider&lt;/a&gt; test on my IE 8 install and then again with chrome frame installed. As i don't know of any sites that will be including the tag above i think JavaScript speed should be an easy test piece.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Internet Explorer 8 had a result of 5484.8ms&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;p&gt;In only a few easy steps, i simply logged onto the chrome frame Google code site @ &lt;a title="http://code.google.com/chrome/chromeframe/" href="http://code.google.com/chrome/chromeframe/"&gt;http://code.google.com/chrome/chromeframe/&lt;/a&gt; clicked on install, agreed to one of Google’s not-so-“Do no evil” EULA’s and i was away.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/ChromeFrameInstall_2.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ChromeFrameInstall" border="0" alt="ChromeFrameInstall" src="http://www.diaryofaninja.com/asset/blogimages/ChromeFrameInstall_thumb.gif" width="400" height="131" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;And again from the top…&lt;/h3&gt;

&lt;p&gt;So lets see what happens now i have the plug-in installed. I pointed at the same address with the cf: in-front of the start URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With Chrome Frame installed my new result is: 525ms&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that’s a “l33t h4x0r” mod that everyone should have.&lt;/p&gt;

&lt;p&gt;So there you have it kids – if you want Chrome’s performance but can’t upgrade yet because yous Sys Admin won’t allow it – Install Chrome Frame.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/Zpoa6tlnpeQ" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/23/google-chrome-frame--chrome-comes-to-ie</feedburner:origLink></item><item><title>Random file, Zip and PDF tracking using jQuery &amp;amp; Google Analytics</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/nINWBFSM6Wk/random-file-zip-and-pdf-tracking-using-jquery-amp-google-analytics</link><description>&lt;p&gt;I use Google Analytics a lot day to day to help my clients better understand their visitors. As Google Analytics is a remotely hosted statistics solution that uses JavaScript it doesn’t track files downloaded like a regular log file analyser would. So today we’re going to talk about how we can track those file downloads so that you can gain better metrics on documents hosted by your site. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.diaryofaninja.com/asset/blogimages/GoogleAnalytics-Intro_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="GoogleAnalytics Screen shot" border="0" alt="GoogleAnalytics Screen shot" align="right" src="http://www.diaryofaninja.com/asset/blogimages/GoogleAnalytics-Intro_thumb.png" width="259" height="167" /&gt;&lt;/a&gt;Tracking users downloading your files can be a great way to tell if users are using your site as you intended. As an example, If you have a business site that hosts PDF files and zip files for customers to download you probably want to know if, and how many times these documents are being downloaded to gain a better understanding on how successful your site’s flow is. &lt;/p&gt;  &lt;p&gt;The official Google Analytics developer documentation says that you can fire a page view event manually like below:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;p&gt;onclick=&amp;quot;pageTracker._trackPageview('/my_filename.extension')“&lt;/p&gt;&lt;/pre&gt;

&lt;p&gt;However, adding an onclick event to every download link in your website in some instances could be downright painful.&lt;/p&gt;

&lt;h3&gt;jQuery + Mindless tasks = Happy Ninja&lt;/h3&gt;

&lt;p&gt;As many of you already know by now &lt;a href="http://www.jquery.com" target="_blank"&gt;jQuery&lt;/a&gt; is a serious force to be reckoned with in the JavaScript world. It is both elegant and extremely powerful and in our current case – its a life saver.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;File types we’d like to track that JavaScript tracking doesn’t capture:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;doc, docx,&amp;#160; eps, xls, xlsx, jpg, png, svg, pdf, zip, txt, ppt, vsd, vxd, js, css, rar, exe, wma, mov, avi, wmv, mp3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now the list above could be longer, it might want to include something special for your implementation, I’ll leave the addition of new file types up to you. &lt;/p&gt;

&lt;h3&gt;Lets make it happen&lt;/h3&gt;

&lt;p&gt;So your first step before continuing should be to mosey on over to the jQuery site and download the latest version. Once downloaded link to it in between your &lt;strong&gt;&amp;lt;head&amp;gt;&lt;/strong&gt; tags like so:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type &lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;src&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;/Js/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; 
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;What we want is a simple bit of code that detects all the links on a page and checks to see if:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;It is a local link to something on your site &lt;/li&gt;

  &lt;li&gt;It is to a file type that matches our list above &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Wrap that up in some anonymous methods and we have the following:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt;
&lt;/span&gt;$(document).ready(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
    &lt;span style="color: green"&gt;// grab each link on the page
    &lt;/span&gt;$(&lt;span style="color: #a31515"&gt;'a'&lt;/span&gt;).each(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
    
        &lt;span style="color: green"&gt;// extract the link address from the link
        &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;strLink = $(&lt;span style="color: blue"&gt;this&lt;/span&gt;).attr(&lt;span style="color: #a31515"&gt;&amp;quot;href&amp;quot;&lt;/span&gt;);
    
        &lt;span style="color: green"&gt;// check if its a link to one of our list
        &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(IsLocalTrackableLink(strLink)) {
        
            &lt;span style="color: green"&gt;// add an onclick method to it
            &lt;/span&gt;$(&lt;span style="color: blue"&gt;this&lt;/span&gt;).click(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
            
                &lt;span style="color: green"&gt;// run the google page view function
                &lt;/span&gt;pageTracker._trackPageview(strLink);
            });
        } 
    });
});

&lt;span style="color: blue"&gt;function &lt;/span&gt;IsLocalTrackableLink(linkUrl) {
    &lt;span style="color: green"&gt;// check that a link is not null, local, 
    // and contains our file extensions
    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(linkUrl != &lt;span style="color: blue"&gt;null &lt;/span&gt;&amp;amp;&amp;amp; 
        linkUrl.indexOf(&lt;span style="color: #a31515"&gt;&amp;quot;http://&amp;quot;&lt;/span&gt;) &amp;lt; 0 &amp;amp;&amp;amp; 
        linkUrl.match(/\.(?:doc|xls|pdf|zip|rar|exe|mp3)($|\&amp;amp;|\?)/)) {
        &lt;span style="color: blue"&gt;return true&lt;/span&gt;;
    }
    &lt;span style="color: blue"&gt;return false&lt;/span&gt;;
}
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Now you’ll notice that the above has been modified to only include a short list of files. I did this simply to make sure they would all fit on the page properly, and you should have no problem adding more using the same format or &lt;strong&gt;|extension|&lt;/strong&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/nINWBFSM6Wk" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/17/random-file-zip-and-pdf-tracking-using-jquery-amp-google-analytics</feedburner:origLink></item><item><title>Getting a full ASP.Net rendered page as a string</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/77lBKKGQ6Cs/a-simple-solution-to-viewing-a-preview-of-any-page-in-your-site</link><description>&lt;p&gt;So there i was looking for a simple solution to offer a preview function on a CMS for a client at work, when it hit me. Why try and replicate the content of the page in anyway (i could use a blank page and fill it in, i could carry values as a session and redirect to the front end view page. The reality is: I could do many different things. The real question comes down to “How would a Ninja do it”&lt;/p&gt;  &lt;p&gt;The CMS i was working on uses dynamic master pages and virtual URL’s (nothing really special here) but it does offer a few issues that i was so blissfully unaware of (i didn’t even stop to really think about it much.&lt;/p&gt;  &lt;h3&gt;“Let's ‘Av a Go Gov!”&lt;/h3&gt;  &lt;p&gt;So my first thought, while on the right track, was a bit naive. I thought i could simply make my CMS “View” (we are still using webforms here but hey, don’t hate on me too much) have a bunch of public properties, set the properties and then use the HttpContext to execute the page and we’d be there. I’d used this technique to make easily templat’able Ajax return values for quick and dirty Ajax return strings in the past.&lt;/p&gt;  &lt;p&gt;My first attempt looked like:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;Page &lt;/span&gt;tempPage = &lt;span style="color: blue"&gt;new &lt;/span&gt;Views.Blog.&lt;span style="color: #2b91af"&gt;BlogDetail&lt;/span&gt;();
tempPage.PageIntro = intro;
tempPage.PageContent = content;

&lt;span style="color: #2b91af"&gt;StringWriter &lt;/span&gt;sw = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StringWriter&lt;/span&gt;();
&lt;span style="color: #2b91af"&gt;HttpContext&lt;/span&gt;.Current.Server.Execute(tempPage, sw, &lt;span style="color: blue"&gt;false&lt;/span&gt;);
&lt;span style="color: blue"&gt;if &lt;/span&gt;(!&lt;span style="color: #2b91af"&gt;String&lt;/span&gt;.IsNullOrEmpty(sw.ToString()))
{
    &lt;span style="color: blue"&gt;return &lt;/span&gt;sw.ToString();
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Sadly this didn’t work. My content view sets its MasterPage dynamically and the method that was doing this &lt;a href="http://www.urbandictionary.com/define.php?term=fantasmagorical" target="_blank"&gt;fantasmagorical&lt;/a&gt; action was having the &lt;strong&gt;null-reference-exception of doom&lt;/strong&gt; because it couldn’t find the &lt;strong&gt;Page.Master &lt;/strong&gt;object… Why????&lt;/p&gt;

&lt;p&gt;While my frustration brewed away it dawned on me: &lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The Asp.Net Engine adds a hell of a lot of pretty cool stuff for us at runtime, that we often forget – we need to make sure this cool stuff still happens.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;How silly of me to forget.&lt;/p&gt;

&lt;p&gt;So i needed to run the page through its full life cycle to get the &lt;em&gt;whole &lt;/em&gt;page. This is where our buddy the BuildManager steps out of the corner and tags himself in. His mystery precedes him and his secret toolbox of helper methods, and i needed some serious inspector gadget goodness. Assuming the fact that he does this all the time (build pages), he know a lot more about what needs to be done in this situation.&lt;/p&gt;

&lt;p&gt;So here is the new updated version, that works a charm and yet its simplicity is nice.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public string &lt;/span&gt;GetCMSPageAsString(&lt;span style="color: blue"&gt;string &lt;/span&gt;intro, &lt;span style="color: blue"&gt;string &lt;/span&gt;content)
{
    &lt;span style="color: green"&gt;// use the Build Manager to create a new instance
    // of the page and set up its properties
    &lt;/span&gt;Views.Blog.&lt;span style="color: #2b91af"&gt;BlogDetail &lt;/span&gt;objContentPage = 
        &lt;span style="color: #2b91af"&gt;BuildManager&lt;/span&gt;.CreateInstanceFromVirtualPath(&lt;span style="color: #a31515"&gt;&amp;quot;~/Views/ContentPage.aspx&amp;quot;&lt;/span&gt;, 
        &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Page&lt;/span&gt;)) &lt;span style="color: blue"&gt;as &lt;/span&gt;Views.Blog.&lt;span style="color: #2b91af"&gt;BlogDetail&lt;/span&gt;;
    
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(objContentPage != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
    {
        &lt;span style="color: green"&gt;//set the pages properties
        &lt;/span&gt;objContentPage.PageIntro = intro;
        objContentPage.PageContent = content;

        &lt;span style="color: #2b91af"&gt;StringWriter &lt;/span&gt;sw = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StringWriter&lt;/span&gt;();
        &lt;span style="color: green"&gt;//set the relative path of the page so it knows where it &amp;quot;is&amp;quot;
        &lt;/span&gt;objContentPage.AppRelativeVirtualPath = &lt;span style="color: #a31515"&gt;&amp;quot;~/Views/ContentPage.aspx&amp;quot;&lt;/span&gt;;
        
        &lt;span style="color: green"&gt;//execute the page
        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HttpContext&lt;/span&gt;.Current.Server.Execute(objContentPage, sw, &lt;span style="color: blue"&gt;false&lt;/span&gt;);
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(!&lt;span style="color: #2b91af"&gt;String&lt;/span&gt;.IsNullOrEmpty(sw.ToString()))
        {
            &lt;span style="color: green"&gt;//return the page as a string
            &lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;sw.ToString();
        }
    }
    &lt;span style="color: blue"&gt;return
          &lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;There was an Error generating your preview&amp;quot;&lt;/span&gt;;
}&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;We still make the page have all its properties made public, we create a new version of the page, set all its properties and then monsieur BuildManager does his stuff. Great Stuff.&lt;/p&gt;

&lt;p&gt;I will be using this quite a bit moving forward. I hope someone can find some use for it too.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/77lBKKGQ6Cs" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/14/a-simple-solution-to-viewing-a-preview-of-any-page-in-your-site</feedburner:origLink></item><item><title>Regular Expression to find the YouTube video ID from a string</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/yaf6FrkBXlE/regular-expression-to-find-the-youtube-video-id-from-a-string</link><description>&lt;p&gt;Today i had to write a quick method to extract the YouTube video id from a YouTube video URL. So on with the show, lets get onto the code.&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private string &lt;/span&gt;GetYouTubeID(&lt;span style="color: blue"&gt;string &lt;/span&gt;youTubeUrl)
{
    &lt;span style="color: green"&gt;//Setup the RegEx Match and give it 
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Match &lt;/span&gt;regexMatch = &lt;span style="color: #2b91af"&gt;Regex&lt;/span&gt;.Match(youTubeUrl, &lt;span style="color: #a31515"&gt;&amp;quot;^[^v]+v=(.{11}).*&amp;quot;&lt;/span&gt;, &lt;br /&gt;                       &lt;span style="color: #2b91af"&gt;RegexOptions&lt;/span&gt;.IgnoreCase);
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(regexMatch.Success)
    {
        &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;http://www.youtube.com/v/&amp;quot; &lt;/span&gt;+ regexMatch.Groups[1].Value + &lt;br /&gt;               &lt;span style="color: #a31515"&gt;&amp;quot;&amp;amp;hl=en&amp;amp;fs=1&amp;quot;&lt;/span&gt;;
    }
    &lt;span style="color: blue"&gt;return &lt;/span&gt;youTubeUrl;
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/yaf6FrkBXlE" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/14/regular-expression-to-find-the-youtube-video-id-from-a-string</feedburner:origLink></item><item><title>Start of something new</title><link>http://feedproxy.google.com/~r/DiaryOfANinja/~3/5QZxkye8nhI/start-of-something-new</link><description>&lt;p&gt;I recently took Rob Conery of &lt;a href="http://www.subsonicproject.com" target="_blank"&gt;SubSonic&lt;/a&gt; fame’s advice and decided it was &lt;a href="http://blog.wekeroad.com/blog/be-a-good-jedi-build-your-own-blog/" target="_blank"&gt;time to be a good Jedi&lt;/a&gt; and build my own blog engine – on a side note: If you haven’t jumped in and at the very least tried Subsonic well… “friendship over”, not much else i can say. Obviously if you want to write a blog engine, there is no better way than to create your own blog using it – So here goes!&lt;/p&gt;  &lt;p&gt;Back on-topic: Rob thinks that a good developer should write their own blog engine and make it their resume. I agree. I’ve been a web developer for nearly 10 years and yet i haven’t had a good website for myself for well over 5 years – i always relied on previous work to prop up my resume and i did quite well from it. But as Rob puts it i didn’t feel like a true “Jedi”.&lt;/p&gt;  &lt;h3&gt;Something tells me, I’m into something good…&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://localhost:4770/asset/blogimages/OntoSomethingNew_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="OntoSomethingNew" border="0" alt="OntoSomethingNew" src="/asset/blogimages/OntoSomethingNew_thumb.jpg" width="240" height="240" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Herman’s Hermits &lt;a href="http://www.youtube.com/watch?v=zxDh2sYQRpo&amp;amp;feature=related" target="_blank"&gt;said it best&lt;/a&gt; and i can’t wait to get started. After working on hundreds of clients, implementing cool features that were taken for granted, along with many of the other issues that come from being a web dev, i think its time to strike out for myself.&lt;/p&gt;  &lt;p&gt;Welcome to “Diary of a Ninja”. This is my new foray into the Blog world, and i hope to use it to share some of the cool things i do at work everyday, solutions to problems, code snippets i think are &lt;a href="http://japanese.about.com/library/blqow41.htm" target="_blank"&gt;banzai&lt;/a&gt; as well as anything else i feel arrogant enough to make myself feel special by sharing (Yes, i do believe blogging, or “evangelizing” as some people refer to it as an arrogant past time, even if it is to benefit others).&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/DiaryOfANinja/~4/5QZxkye8nhI" height="1" width="1"/&gt;</description><pubDate>3/11/2010 3:01:25 AM</pubDate><feedburner:origLink>http://www.diaryofaninja.com/blog/2009/09/13/start-of-something-new</feedburner:origLink></item></channel></rss>
