<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-248768039922594980</id><updated>2012-02-04T14:03:43.990-08:00</updated><title type='text'>Steven Maglio's Homework</title><subtitle type='html'>.NET, OSS &amp;amp; a little more</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-8475508435621014518</id><published>2011-10-07T02:46:00.001-07:00</published><updated>2011-10-07T03:04:43.689-07:00</updated><title type='text'>Testing a local IIS website with a VM</title><content type='html'>&lt;p&gt;I had been putting off updating to IE9 for a while because 9’s “IE8 Mode” didn’t perfectly replicate IE8. Fortunately, a coworker pointed out that you can test out a local website using a VM.&lt;/p&gt;  &lt;p&gt;I’m gonna use &lt;a href="https://www.virtualbox.org/wiki/Downloads"&gt;VirtualBox&lt;/a&gt; as the VM host software. I used an old copy of XP that I have lying around and updated it to IE8 (and security updates).&lt;/p&gt;  &lt;p&gt;The virtual machine I created uses a NAT network interface. Most of the &lt;a href="http://stackoverflow.com/questions/2769601/debug-website-on-host-from-virtual-machine"&gt;questions&lt;/a&gt; over on StackOverflow suggest using a Bridged interface, but I was having trouble getting that going.&lt;/p&gt;  &lt;p&gt;Once you have the virtual machine up, all you have to do is edit your hosts file (C:\Windows\system32\drivers\etc) to map a dns address (eg. vmtest.local.mycomputer.com) to the local IP address of your machine (eg. 192.168.1.X).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-njPKMQa1dgo/To7KcFS7kjI/AAAAAAAAAEo/zSANldHiCMQ/s1600-h/image%25255B8%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-g6zh-DwsQLo/To7KcVnc5HI/AAAAAAAAAEs/2rsS3SaNpAE/image_thumb%25255B3%25255D.png?imgmax=800" width="385" height="99" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As long as your local IIS instance uses host names to determine what the processing website is, then it will work.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-zfeS1Mma4FY/To7KcqX73fI/AAAAAAAAAEw/ad1K-bTJORE/s1600-h/image4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-ngfiPs4GcYA/To7KcnLIAaI/AAAAAAAAAE0/clxPNbG3Rzs/image_thumb2.png?imgmax=800" width="342" height="201" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Inside of your VM, you should now be able to type in the address and get a result.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-KOwXEEF8dWU/To7Kc7bK1nI/AAAAAAAAAE4/2mbavCFD8Co/s1600-h/image%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-l0yYXvZklKI/To7KdKjNE_I/AAAAAAAAAE8/Wz9lYFrB1fg/image_thumb%25255B1%25255D.png?imgmax=800" width="472" height="178" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;With SSL certs it’s a little more tricky. You have to bind an SSL cert with an IP address. In this case, the only way to really do it is to bind the SSL cert either to ‘All Unassigned’ or to the actual IP address of the machine. If you already have a cert bound to ‘All Unassigned’ associated with any website it should just work.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-CBxxC2IlB-o/To7KdSxHSLI/AAAAAAAAAFA/XBfspC0gBlg/s1600-h/image10.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-MacNUuYVAYM/To7KdurQH3I/AAAAAAAAAFE/duSpcHswWLI/image_thumb6.png?imgmax=800" width="346" height="209" /&gt;&lt;/a&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b746bfbe-3005-47ff-b09a-a456e03d9042" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/IIS" rel="tag"&gt;IIS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VM" rel="tag"&gt;VM&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Virtual+Machine" rel="tag"&gt;Virtual Machine&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Testing" rel="tag"&gt;Testing&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VirtualBox" rel="tag"&gt;VirtualBox&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-8475508435621014518?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/8475508435621014518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2011/10/testing-local-iis-website-with-vm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/8475508435621014518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/8475508435621014518'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2011/10/testing-local-iis-website-with-vm.html' title='Testing a local IIS website with a VM'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-g6zh-DwsQLo/To7KcVnc5HI/AAAAAAAAAEs/2rsS3SaNpAE/s72-c/image_thumb%25255B3%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-3256381029070416443</id><published>2010-08-07T00:03:00.001-07:00</published><updated>2010-08-07T10:18:30.463-07:00</updated><title type='text'>Enabling IIS Extensions for ASP.NET</title><content type='html'>&lt;p&gt;Recently, I ran into a server which was running ColdFusion, but wasn’t ASP.NET extensions. It was really confusing because ASP.NET 2.0 was listed as a possible extension under IIS. But, after we copied over an ASP.NET website, the only result was a 404 page not found.&lt;/p&gt;  &lt;p&gt;After looking through the IIS logs, I found the &lt;a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/bea506fd-38bc-4850-a4fb-e3a0379d321f.mspx?mfr=true"&gt;404 entry&lt;/a&gt;. There was sub-status code of 2 (&lt;a href="http://support.microsoft.com/kb/318380"&gt;Web service extension lockdown policy prevents this request&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;So, I started to look up how “service extensions” worked. Which didn’t take much …&lt;/p&gt;  &lt;p&gt;After a little looking with google, I ran aground the ability to &lt;a href="http://support.microsoft.com/kb/328360/"&gt;enable and disable ISAPI extensions with the command line&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Unfortunately, ASP.NET had been turned off. I would guess that it had been done with purpose, as no ASP/ASP.NET application websites were running before. But, the new website needed ASP.NET. So, with a few command line statements it was turned back on (iisext) …&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_DoBtBBqas2w/TF0FTJ1vo7I/AAAAAAAAABY/DQwRCeteZXw/s1600-h/ScreenHunter_02%20Aug.%2003%2018.12%5B4%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ScreenHunter_02 Aug. 03 18.12" border="0" alt="ScreenHunter_02 Aug. 03 18.12" src="http://lh4.ggpht.com/_DoBtBBqas2w/TF0FTbjZaAI/AAAAAAAAABc/crlEkG0MzJI/ScreenHunter_02%20Aug.%2003%2018.12_thumb%5B2%5D.jpg?imgmax=800" width="544" height="714" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-3256381029070416443?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/3256381029070416443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2010/08/enabling-iis-extensions-for-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/3256381029070416443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/3256381029070416443'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2010/08/enabling-iis-extensions-for-aspnet.html' title='Enabling IIS Extensions for ASP.NET'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_DoBtBBqas2w/TF0FTbjZaAI/AAAAAAAAABc/crlEkG0MzJI/s72-c/ScreenHunter_02%20Aug.%2003%2018.12_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-4540878419305623169</id><published>2010-02-24T20:28:00.001-08:00</published><updated>2010-02-24T20:28:58.236-08:00</updated><title type='text'>Just Drop It In</title><content type='html'>&lt;p&gt;I recently helped out a friend who was trying to install a processor. I arrived late to the party and he tried to force the processor in when the pins weren’t lined up. So I told him “You should be able to take the processor and move it around the surface. When the pins line up it will just drop into the slot.” He questioned, “It doesn’t seem to fit?” So I told him, “You should try to line it up and when it fits it will just go. Once it’s in, then you can get the rest of the work done.”&lt;/p&gt;  &lt;p&gt;His Girlfriend started laughing.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-4540878419305623169?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/4540878419305623169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2010/02/just-drop-it-in.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/4540878419305623169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/4540878419305623169'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2010/02/just-drop-it-in.html' title='Just Drop It In'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-4202661604325767979</id><published>2010-01-26T23:32:00.001-08:00</published><updated>2010-01-26T23:45:53.072-08:00</updated><title type='text'>Joel Spolsky is a BadAss once again</title><content type='html'>&lt;p&gt;So, this has probably been discussed by thousands of bloggers. But, Joel Spolsky “revealed” one of the questions he asks to potential interns (&lt;a href="http://itc.conversationsnetwork.org/shows/detail4359.html"&gt;http://itc.conversationsnetwork.org/shows/detail4359.html&lt;/a&gt;). But, I want to take my stab at it; and how to think about it as an interviewer.&lt;/p&gt;  &lt;p&gt;Before hand; here’s Joel Spolsky’s description about why he setup this test: “Asking them to code in front of you is a way for you to figure out if they are smart. … We want to see them doing it. Because, we want to hear them think, we want to see them think, we want to see how quickly they are doing it. We want proof they can do it. Because anybody can generate code for a million dollars. To get a job they will somehow find a way. You think they’re not asking their friends for help?” (summarized quote).&lt;/p&gt;  &lt;p&gt;The question he asked was:&lt;/p&gt;  &lt;p&gt;“Given an array of numbers. And, given a pointer into the middle of the array of numbers. It doesn’t have to be the middle, just an element within that array of number. Like the 37th element. Does all of the numbers summed up to the left of that pointer equal the sum of all the elements to the right of that pointer?”&lt;/p&gt;  &lt;p&gt;When I was listening to that podcast my brain immediately sprung into work. Ignoring the rest of Joel’s words, I started trying to figure out how to program a solution to the problem. My initial solution to the problem was really ugly, because I started thinking of the solution as soon as he said “37th”. It was like my brain started to solve an SAT problem without reading the whole question.&lt;/p&gt;  &lt;p&gt;So, I jumped on the computer, loaded up VS, and started to write a function that would do the quick and dirty solution:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;static bool IsArrayEqual(int[] arr, int splitIndex)&lt;br /&gt;{&lt;br /&gt;    int leftSum = 0, rightSum = 0;&lt;br /&gt;&lt;br /&gt;    for (int i = 0; i &amp;lt; arr.Length; i++)&lt;br /&gt;    {&lt;br /&gt;        if (i == splitIndex)&lt;br /&gt;        {&lt;br /&gt;            i++;&lt;br /&gt;            continue;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        if (i &amp;lt; splitIndex)&lt;br /&gt;        {&lt;br /&gt;            leftSum += arr[i];&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            rightSum += arr[i];&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    return leftSum == rightSum;&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;As you can see the solution featured a straight O(n) algorithm with if statements in between.&lt;/p&gt;&lt;p&gt;It was a&amp;#160; really stupid solution. As soon as I looked over the code the first gut wrenching reaction was to remove the if statements. If statements are always branch statements to the compiler; and if the forward look ahead fails then they are costly. So, I rewrote the function to exclude the if statements.&lt;/p&gt;&lt;pre class="brush: csharp;"&gt;static bool IsArrayValuesEqual(int[] arr, int splitIndex, out int leftSum, out int rightSum )&lt;br /&gt;{&lt;br /&gt;    leftSum     = SliceSum(arr, 0, splitIndex - 1);&lt;br /&gt;    rightSum    = SliceSum(arr, splitIndex + 1, arr.Length - 1);&lt;br /&gt;&lt;br /&gt;    return leftSum == rightSum;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static int SliceSum(int[] arr, int startIndex, int endIndex)&lt;br /&gt;{&lt;br /&gt;    int sum = 0;&lt;br /&gt;    for (int i = startIndex; i &amp;lt; endIndex; i++)&lt;br /&gt;        sum += arr[i];&lt;br /&gt;    return sum;&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;At this point I was pretty proud of myself. With no reason to be. Why be proud of a solution to an intern question? Because I was able to figure out an answer in under 5 minutes? Because no entry level programmer could write this code? WTF?? This code is “entry level”. The only reason I know it is because I know of all the .NET design practices that make this code shit. So, I was proud of shit code.&lt;/p&gt;&lt;p&gt;At this point I decided that I was going to going to make something useful out of this wasted time. I hadn’t thought of blogging about this (and, as I am blogging about this; I still don’t think of this as a useful means to my wasted time). But, I did think there must be a better way to look at the problem and find some usage from it.&lt;/p&gt;&lt;p&gt;It hit me immediately, I should make a comparison test. Something like a unit test, but not as useful. I should write a loop which will dynamically populate the integer array and when the elements to the left of the pointer are equal to the elements to the right of the pointer it will be a success:&lt;/p&gt;&lt;pre class="brush: csharp;"&gt;var rand = new Random(DateTime.Now.Millisecond);&lt;br /&gt;bool isEqual;&lt;br /&gt;do&lt;br /&gt;{&lt;br /&gt;    int[] arr = new int[100];&lt;br /&gt;    for (int i = 0; i &amp;lt; arr.Length; i++)&lt;br /&gt;    {&lt;br /&gt;        arr[i] = rand.Next(100);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    isEqual = IsArrayEqual(arr, 37);&lt;br /&gt;    Console.WriteLine(&amp;quot;Are equal: {0}&amp;quot;, isEqual);&lt;br /&gt;} while (!isEqual);&lt;/pre&gt;&lt;p&gt;The test worked around the 100000th try, but I was confused by the way my computer handled the test. I thought that my computer would eat up all processor time trying to produce a result. But it didn’t. It used 2 processors. And, my comp has 8 procs (Core i7). So, I decided to rewrite the test code to use the Parallel library in .NET 4.0.&lt;/p&gt;&lt;p&gt;That turned into a bit of a research mission. Apparently, I couldn’t use the Parallel library without a For loop. And, my algorithm was using a Do … While loop. What was I to do? After a little looking, I found that .NET 4.0 allowed for multi-threading through lamba expressions and anonymous functions. It wasn’t the same as a Parallel loop, but it allowed for multi-threading.&lt;/p&gt;&lt;p&gt;So, I added a wrapper function around the code and executed multiple threads using anonymous functions:&lt;/p&gt;&lt;pre class="brush: csharp;"&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Threading.Tasks;&lt;br /&gt;&lt;br /&gt;namespace FogCreekInternTest&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            &lt;br /&gt;            int j = 0;&lt;br /&gt;            var isEqual = false;&lt;br /&gt;            int leftSum, rightSum;&lt;br /&gt;            var rand = new Random(DateTime.Now.Millisecond);&lt;br /&gt;            var found = false;&lt;br /&gt;&lt;br /&gt;            for (int t = 0; t &amp;lt; 5; t++)&lt;br /&gt;            {&lt;br /&gt;                Task.Factory.StartNew&amp;lt;bool&amp;gt;((threadNumber) =&amp;gt;&lt;br /&gt;                {&lt;br /&gt;                    do&lt;br /&gt;                    {&lt;br /&gt;                        int[] arr = new int[100];&lt;br /&gt;                        for (int i = 0; i &amp;lt; arr.Length; i++)&lt;br /&gt;                        {&lt;br /&gt;                            arr[i] = rand.Next(100);&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;                        isEqual = IsArrayValuesEqual(arr, 37, out leftSum, out rightSum);&lt;br /&gt;                        Console.WriteLine(&amp;quot;[{4}:{0}] Are equal: {1}\tleftSum: {2}, rightSum: {3}&amp;quot;, j++, isEqual, leftSum, rightSum, threadNumber);&lt;br /&gt;                    } while (isEqual == found);&lt;br /&gt;&lt;br /&gt;                    found = true;&lt;br /&gt;                    return isEqual;&lt;br /&gt;                }, t );&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            Console.ReadKey();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static bool IsArrayValuesEqual(int[] arr, int splitIndex, out int leftSum, out int rightSum )&lt;br /&gt;        {&lt;br /&gt;            leftSum     = SliceSum(arr, 0, splitIndex - 1);&lt;br /&gt;            rightSum    = SliceSum(arr, splitIndex + 1, arr.Length - 1);&lt;br /&gt;&lt;br /&gt;            return leftSum == rightSum;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static int SliceSum(int[] arr, int startIndex, int endIndex)&lt;br /&gt;        {&lt;br /&gt;            int sum = 0;&lt;br /&gt;            for (int i = startIndex; i &amp;lt; endIndex; i++)&lt;br /&gt;                sum += arr[i];&lt;br /&gt;            return sum;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;With some testing, I discovered: With 1 thread I used 2 processors. With 2 threads I used 4 processors, with 3 threads I used 6, with 4 I used all 8. And with 5 threads I used all 8 to 80%.&lt;/p&gt;&lt;p&gt;In the end, I was able to do some real research; the parallel library in .NET 4.0 is pretty good. You just need to have a good reason to use it. &lt;/p&gt;&lt;p&gt;Now … How to think about it as an interviewer:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Giving programmers take home assignments is stupid.&lt;/li&gt;&lt;li&gt;Giving a coding test that you have to write out on paper is stupid.&lt;/li&gt;&lt;li&gt;Bringing an interviewee into the office without doing a basic “look over the shoulder” programming test is stupid.&lt;/li&gt;&lt;li&gt;Phone interviews are antiquated if you have the capability to remote desktop into a developers computer.&lt;/li&gt;&lt;li&gt;Asking a developer to solve one problem in front of you is more useful than asking a hundred “do you know about this” questions.&lt;/li&gt;&lt;li&gt;If a programmer can demonstrate ability while your looking over their shoulder; then the only question left to ask is “will you fit in with our development team”.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Sidenote: “How much money do you want?” should be an initial question. Why waste time on a developer who has dreams of a Midas touch?&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-4202661604325767979?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/4202661604325767979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2010/01/joel-spolsky-is-badass-once-again.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/4202661604325767979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/4202661604325767979'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2010/01/joel-spolsky-is-badass-once-again.html' title='Joel Spolsky is a BadAss once again'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-2099812990907587470</id><published>2010-01-26T00:53:00.001-08:00</published><updated>2010-01-26T14:38:29.370-08:00</updated><title type='text'>Using Google Closure Compiler with .NET</title><content type='html'>&lt;p&gt;Well, with C#.NET.&lt;/p&gt;  &lt;p&gt;I maintain a service which updates the minified versions of reused Javascript libraries. It runs at a specified time each night, and will check through all javascript code within a directory for two things:&lt;/p&gt;  &lt;p&gt;1) If a .js doesn’t have a .min.js file; then a minified version of the file is created.&lt;/p&gt;  &lt;p&gt;2) If a .js file does have a .min.js file which is out of date; then a new minified version of the file is created.&lt;/p&gt;  &lt;p&gt;(aka, its a nightly run service which updates all minified version of javascript librarys on a server)&lt;/p&gt;  &lt;p&gt;This service has a couple of problems on the surface. Why doesn’t it also make a packed file version? Does the minified version always perform (without error) the same as the development version? And, what “minifier” does it use?&lt;/p&gt;  &lt;p&gt;Here’s are some quick answers:&lt;/p&gt;  &lt;p&gt;1) “Packed Version”:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000"&gt;Unfortunately, when I first created the service only minified files were being created (aka, a long time ago in a land far far away). And, I haven’t yet had time to implement “packed versions”. It should only take a night to do update the source code. But when will I have that night?&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;2) What language?&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000"&gt;C#. Sorry all, but it’s the easiest for me to use.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#000000"&gt;3) Does the minified version always perform (without error) the same as the development version?&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000"&gt;It depends on the “minifier”.&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000"&gt;I have found that “jsmin” doesn’t really translate the code that well. YUI is pretty good; but not 100% accurate. It’s about 99% accurate.&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000"&gt;This system does support the Microsft Implementation of javscript minifying … but I have never used it. Because …&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000"&gt;Google’s implementation was pretty damn good. I have never had an error/problem with a file minimized through the google closure compiler (&lt;a href="http://closure-compiler.appspot.com/home"&gt;http://closure-compiler.appspot.com/home&lt;/a&gt;).&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;3) What “minifier” does it use?&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000"&gt;Thankfully, I made the program agnositic to what minifier was used. Currently, it supports “jsmin”, “ajaxmin” (MS), “YuiCompressor”, and “Closure” (Google).&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Hopefully, you can copy/paste this into your project and be able to use Google Closure-Compiler.&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;//    So, this is different than most of the other compilers because it uses a remote (web) service.&lt;br /&gt;//    the first thing is to read in the javascript file.&lt;br /&gt;string    fileContents;&lt;br /&gt;using( var fileReader = new StreamReader( info.FullName ) )&lt;br /&gt;{&lt;br /&gt;    fileContents    = fileReader.ReadToEnd();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//    The files contents have been read. Now they need to be formatted in a POST request with the&lt;br /&gt;///    file contents URL encoded.&lt;br /&gt;const string postFormat    = &amp;quot;js_code={0}&amp;amp;compilation_level={1}&amp;amp;output_format={2}&amp;amp;output_info={3}&amp;quot;;&lt;br /&gt;var data    = string.Format(&lt;br /&gt;    postFormat,&lt;br /&gt;    HttpUtility.UrlEncode( fileContents ),&lt;br /&gt;    &amp;quot;WHITESPACE_ONLY&amp;quot;,&lt;br /&gt;    &amp;quot;text&amp;quot;,&lt;br /&gt;    &amp;quot;compiled_code&amp;quot;&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;//    finally, create the Http Request (POST request)&lt;br /&gt;var request    = WebRequest.Create( &amp;quot;http://closure-compiler.appspot.com/compile&amp;quot; );&lt;br /&gt;request.Method    = &amp;quot;POST&amp;quot;;&lt;br /&gt;request.ContentType        = &amp;quot;application/x-www-form-urlencoded&amp;quot;;&lt;br /&gt;&lt;br /&gt;//    and, write the contents to the request.&lt;br /&gt;using( var dataStream    = new StreamWriter( request.GetRequestStream() ) )&lt;br /&gt;{&lt;br /&gt;    dataStream.Write( data );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//    the response contains the javascript&lt;br /&gt;var response    = request.GetResponse();&lt;br /&gt;using( var responseStream    = response.GetResponseStream() )&lt;br /&gt;{&lt;br /&gt;    var streamReader    = new StreamReader( responseStream );&lt;br /&gt;    return streamReader.ReadToEnd();&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;If you would like to see more than just the Google Code portion, or even the whole code for the service please email or comment.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-2099812990907587470?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/2099812990907587470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2010/01/using-google-closure-compiler-with-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/2099812990907587470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/2099812990907587470'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2010/01/using-google-closure-compiler-with-net.html' title='Using Google Closure Compiler with .NET'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-3541678308048738024</id><published>2010-01-25T23:38:00.001-08:00</published><updated>2010-01-25T23:46:18.271-08:00</updated><title type='text'>Invasion of the Blog-o-Snatchers</title><content type='html'>&lt;p&gt;I am thankful for all the blog-o-sphere websites which provide servers and websites for expressing opinions online. This doesn’t just include &lt;a href="http://www.blogger.com"&gt;blogger.com&lt;/a&gt;, &lt;a href="http://wordpress.com/"&gt;wordpress.com&lt;/a&gt;, or &lt;a href="http://www.livejournal.com/"&gt;livejournal.com&lt;/a&gt;. I also include &lt;a href="http://www.wikipedia.org/"&gt;wikipedia&lt;/a&gt; and all of the &lt;a href="http://www.wikia.com/"&gt;wikia.com&lt;/a&gt; websites. And any website which allows people to add their opinions to the eternal flow of electronic information.&lt;/p&gt;&lt;p&gt;These websites are amazing. And they allow for the 80% of the world which isn’t represented by the mainstream news networks, hollywood movies, or local papers to express their opinions and find a community with those opinions.&lt;/p&gt;&lt;p&gt;But, I hate when those websites undermine the opinions of the bloggers or commenters by adding advertisements to a detriment to their content. Advertisements are a necessary part of every information medium, but it doesn’t need to be in your face. Or even worse, detract from the content which the end-user actually went to the website for.&lt;/p&gt;&lt;p&gt;Earlier tonight, I was trying to write a snippet of code which would use the Google Closure Compiler to condense some javascript used on the UCSB websites and ran into this blog post: &lt;a href="http://www.bloggingdeveloper.com/post/C-Wrapper-for-Google-Closure-Compiler-Compressing-Javascript-Files-on-the-fly-with-ASPNET-and-Closure-Compiler.aspx"&gt;http://www.bloggingdeveloper.com/post/C-Wrapper-for-Google-Closure-Compiler-Compressing-Javascript-Files-on-the-fly-with-ASPNET-and-Closure-Compiler.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;It’s a pretty decent post, but the code wasn’t complete. At this point I assumed that their website would have a download section to get the original source code. Near the bottom of the post there is text “Download Closure.cs”, which leads to nothing.&lt;/p&gt;&lt;p&gt;So far this website is zero for three.&amp;#160; I wanted to find some code that “just worked with Closure Compiler”. And I was blown away that the top google result that I found had an image for source code (which I couldn’t copy/paste), had missing variable definitions, and I couldn’t get the source code.&lt;/p&gt;&lt;p&gt;The strange thing is that none of that annoyed me. The source code on the website was very similar to the source code I wrote in my early attempts; so I felt that I was doing the right thing. I had already created a string format, and I didn’t think the real implementation of “data” would solve my problem. But, the idea that I couldn’t download the source from the website bugged me. There was explicit text that said “Download Closure.cs”.&lt;/p&gt;&lt;p&gt;Have you ever created a website that had a link “Download PDF”, and the link didn’t work? How many people complained? Everybody that tried it would complain. Even people that would never use the PDF document would complain that the link didn’t work.&lt;/p&gt;&lt;p&gt;BUT … BUT … That text is not that big on the screen. There is a huge image which says “Download” right below it. That image probably appears on every page, and it probably confuses every person that sees it. The HUGE&amp;#160; “DOWNLOAD” link only allows users to subscribe to an RSS feed. FTW??&lt;/p&gt;&lt;p&gt;What the hell does RSS feeds have to do with Downloading? What RSS feed on the planet Downloads? When has the term download ever been associated with RSS?&lt;/p&gt;&lt;p&gt;At this point I started to look at the website layout and started to notice the big images which say SUBSCRIBE and SPONSORS. Direct advertising! I understand that everybody needs to make money to survive. But, is it neccessary?&lt;/p&gt;&lt;p&gt;What is the business model of blogger, wordpress, and livejournal? How do they make money without pissing off their users?&lt;/p&gt;&lt;p&gt;Any why is anyone using a blogging website that would add content to your posts which you never asked for?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-3541678308048738024?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/3541678308048738024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2010/01/invasion-of-blog-o-snatchers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/3541678308048738024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/3541678308048738024'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2010/01/invasion-of-blog-o-snatchers.html' title='Invasion of the Blog-o-Snatchers'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-2748167006288263734</id><published>2010-01-25T20:47:00.001-08:00</published><updated>2010-01-25T20:59:09.535-08:00</updated><title type='text'>Creating your own javascript namespaces with jQuery</title><content type='html'>&lt;p&gt;This isn’t cutting edge by a long shot, but if I had found a post on this a couple months ago it would have kept me from refactoring my code two or three times. One of the amazing things about working with jQuery is the programmers have dealt with every impossible situation you could imagine. And, when you look through their code you are given an insight into javascript best practices.&lt;/p&gt;  &lt;pre class="brush: js;"&gt;(function ($) {&lt;br /&gt;&lt;br /&gt;    if (!window.baseNamespace) { window.baseNamespace = {}; }&lt;br /&gt;    if (!baseNamespace.subNamespace) { baseNamespace.subNamespace = {}; }&lt;br /&gt;&lt;br /&gt;    var pseudoGlobal = 10;&lt;br /&gt;&lt;br /&gt;    $.extend(baseNamespace.subNamespace, {&lt;br /&gt;        someVariable: 10,&lt;br /&gt;&lt;br /&gt;        someFunction: function () {&lt;br /&gt;            alert(pseudoGlobal);&lt;br /&gt;        }&lt;br /&gt;    });&lt;br /&gt;&lt;br /&gt;})(jQuery);&lt;/pre&gt;&lt;p&gt;Unfortunately, this description doesn’t follow the exact same best practices that jQuery does. But, it works well when defining your own namespaces.&lt;/p&gt;&lt;p&gt;The outer function ensures the inner statements will be executed with jQuery as the definition of $. This will help out if you ever need to reuse your code in “no conflict” mode (&lt;a href="http://api.jquery.com/jQuery.noConflict/"&gt;http://api.jquery.com/jQuery.noConflict/&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;Then, inside of the function, first check that the root namespace is defined under “window”, the global namespace. It took me longer than I would have liked to understand that “window” was the global namespace; I was under the sad impression that “document” was the global namespace.&lt;/p&gt;&lt;p&gt;Once the namespace you are looking to work with is created, then the $.extend() function gives the means to create the functionality you want.&lt;/p&gt;&lt;p&gt;You can then interact with your namespace the same way google of yahoo call their namespaced code:&lt;/p&gt;&lt;pre class="brush: js;"&gt;alert(baseNamespace.subNamespace.someVariable); // 10&lt;br /&gt;baseNamespace.subNamespace.someFunction(); // Also, 10&lt;/pre&gt;&lt;p&gt;I hope this saves you a little bit of time when developing reusable javascript.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-2748167006288263734?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/2748167006288263734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2010/01/creating-your-own-javascript-namespaces.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/2748167006288263734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/2748167006288263734'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2010/01/creating-your-own-javascript-namespaces.html' title='Creating your own javascript namespaces with jQuery'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-580540698299675770</id><published>2009-12-24T23:17:00.001-08:00</published><updated>2009-12-24T23:17:50.619-08:00</updated><title type='text'>Wizmo: Have Windows go to sleep on commad</title><content type='html'>&lt;p&gt;I can’t find the original blog post which pointed out &lt;a href="http://www.grc.com/wizmo/wizmo.htm"&gt;Wizmo&lt;/a&gt;. But, it’s a command line utility which handles a lot of the shutdown/restart/sleep mode capabilities of windows. I needed it to turn my monitors off when I leave home.&lt;/p&gt;  &lt;p&gt;When I go out I like to turn off my monitors. It would be nice to think I was saving electricity, but really I just want to save the monitors. Unfortunately, when I turn off the monitors all of my open windows &lt;a href="http://forums.amd.com/forum/messageview.cfm?catid=347&amp;amp;threadid=122746&amp;amp;forumid=9"&gt;rearrange themselves onto a single screen&lt;/a&gt;. My setup isn’t normal, so I wouldn’t expect for any software or hardware vendor to accommodate it.&lt;/p&gt;  &lt;p&gt;However, Wizmo is able to handle the problem. By creating a simple desktop shortcut, I can turn off all the screens without any of the problems which DisplayPort creates.&lt;/p&gt;  &lt;p&gt;The command line shortcut:&lt;/p&gt;  &lt;pre class="brush: bash;"&gt;&amp;quot;C:\Program Files (x86)\Wizmo\wizmo.exe&amp;quot; monoff&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c1b001c0-99a1-4d44-99bb-9a1109ddd464" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/wizmo" rel="tag"&gt;wizmo&lt;/a&gt;,&lt;a href="http://technorati.com/tags/3+display" rel="tag"&gt;3 display&lt;/a&gt;,&lt;a href="http://technorati.com/tags/tri+head" rel="tag"&gt;tri head&lt;/a&gt;,&lt;a href="http://technorati.com/tags/3+head" rel="tag"&gt;3 head&lt;/a&gt;,&lt;a href="http://technorati.com/tags/3+monitors" rel="tag"&gt;3 monitors&lt;/a&gt;,&lt;a href="http://technorati.com/tags/power+off" rel="tag"&gt;power off&lt;/a&gt;,&lt;a href="http://technorati.com/tags/turn+off" rel="tag"&gt;turn off&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sleep" rel="tag"&gt;sleep&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-580540698299675770?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/580540698299675770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/wizmo-have-windows-go-to-sleep-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/580540698299675770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/580540698299675770'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/wizmo-have-windows-go-to-sleep-on.html' title='Wizmo: Have Windows go to sleep on commad'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-4899180080198958569</id><published>2009-12-24T22:45:00.001-08:00</published><updated>2009-12-24T23:00:47.441-08:00</updated><title type='text'>jBreadCrumb: 0.3.0</title><content type='html'>&lt;p&gt;&lt;a href="http://code.google.com/p/jbreadcrumb/"&gt;http://code.google.com/p/jbreadcrumb/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://code.google.com/p/jbreadcrumb/"&gt;jBreadCrumb&lt;/a&gt; gains the ability to start working in a Web 2.0 world. The addition of methods for ‘add’, ‘remove’, and ‘clear’ allows for a webpage which dynamically loads content into a sub-div or iframe to also update the breadcrumb trail. It’s definitely not perfect, but allows for breadcrumbs to start becoming a dynamic part of the webpage design.&lt;/p&gt;  &lt;p&gt;The new methods can be used by:&lt;/p&gt;  &lt;p&gt;(*note: #addBreadCrumb, #removeBreadCrumb, and #clearBreadCrumb are input buttons on the page. #breadCrumbAdd is the breadcrumb list element to update.)&lt;/p&gt;  &lt;p&gt;Add:&lt;/p&gt;  &lt;p&gt;The options are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;text: (required) the text to display on screen.&lt;/li&gt;    &lt;li&gt;url: (optional, default: ‘#’) the url to apply to the hyperlink&lt;/li&gt;    &lt;li&gt;index: (optional, default: add the breadcrumb to the end of the list) the position to place to breadcrumb (1 based index)&lt;/li&gt; &lt;/ul&gt;  &lt;pre class="brush: csharp;"&gt;$('#addBreadCrumb').click(function(e) {&lt;br /&gt;    var options    = {&lt;br /&gt;        text: $('#addDisplayValue').val(),&lt;br /&gt;        url: $('#addUrl').val(),&lt;br /&gt;        index: $('#addIndex').val()&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    $('#breadCrumbAdd').jBreadCrumb('add',options);&lt;br /&gt;&lt;br /&gt;    e.preventDefault();&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Remove:&lt;/p&gt;&lt;p&gt;The options are:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;index: (optional, default: the last breadcrumb) the position to remove (1 based index)&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;pre class="brush: js;"&gt;$('#removeBreadCrumb').click(function(e) {&lt;br /&gt;    var    options    = {&lt;br /&gt;        index: $('#removeIndex').val()&lt;br /&gt;    };&lt;br /&gt;    $('#breadCrumbAdd').jBreadCrumb('remove',options);&lt;br /&gt;    e.preventDefault();&lt;br /&gt;});&lt;/pre&gt;&lt;p&gt;Clear:&lt;/p&gt;&lt;pre class="brush: js;"&gt;$('#clearBreadCrumb').click(function(e) {&lt;br /&gt;    $('#breadCrumbAdd').jBreadCrumb('clear');&lt;br /&gt;    e.preventDefault();&lt;br /&gt;});&lt;/pre&gt;&lt;p&gt;These functions are useful for my usages. But, do they do what you need?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-4899180080198958569?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/4899180080198958569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/jbreadcrumb-030.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/4899180080198958569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/4899180080198958569'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/jbreadcrumb-030.html' title='jBreadCrumb: 0.3.0'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-3972995568665402234</id><published>2009-12-17T01:45:00.001-08:00</published><updated>2009-12-17T02:09:14.978-08:00</updated><title type='text'>Using JSONP with ASP.NET MVC</title><content type='html'>&lt;p&gt;(I am using the Beta 2 of ASP.NET MVC. It isn’t supposed to be ready for production; but it seems pretty stable.)&lt;/p&gt;  &lt;p&gt;Earlier today I needed create some Cross Domain javascript requests. At first I tried to use the ASP.NET MVC JsonResult to provide data for these requests, but the serialized objects that were returned were unable to be used through JSONP (the cross domain javascript).&lt;/p&gt;  &lt;p&gt;After a little research on StackOverflow (what a great site), I was able to find some JSONP code to use. This was a real timesaver, and it was documented to boot.&lt;/p&gt;  &lt;p&gt;The creators of this code posted their code at:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://stackoverflow.com/questions/758879/asp-net-mvc-returning-jsonp" href="http://stackoverflow.com/questions/758879/asp-net-mvc-returning-jsonp"&gt;http://stackoverflow.com/questions/758879/asp-net-mvc-returning-jsonp&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogorama.nerdworks.in/entry-EnablingJSONPcallsonASPNETMVC.aspx" href="http://blogorama.nerdworks.in/entry-EnablingJSONPcallsonASPNETMVC.aspx"&gt;http://blogorama.nerdworks.in/entry-EnablingJSONPcallsonASPNETMVC.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I’ve added a small update. Just enough to make the Controller handle the new ASP.NET MVC 2 JsonRequestBehavior. I hope someone will improve on this code and add an “extensions” library to allow for Jsonp to be available in all controllers without using the JsonpController or JsonpFilterAttribute.&lt;/p&gt;  &lt;p&gt;JsonpResult.cs:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;using System;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Mvc;&lt;br /&gt;using System.Web.Script.Serialization;&lt;br /&gt;&lt;br /&gt;namespace Ucsb.Sa.Enterprise.Utility.Web.Mvc&lt;br /&gt;{&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// A Jsonp wrapper for the JsonResult.&lt;br /&gt;    /// &lt;br /&gt;    ///    Created by:&lt;br /&gt;    /// stimms (http://stackoverflow.com/questions/758879/asp-net-mvc-returning-jsonp)&lt;br /&gt;    /// Ranju V (http://blogorama.nerdworks.in/entry-EnablingJSONPcallsonASPNETMVC.aspx)&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    public class JsonpResult : JsonResult&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        #region constructor&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Initializes a new instance of &amp;lt;see cref=&amp;quot;JsonpResult&amp;quot; /&amp;gt;.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        public JsonpResult()&lt;br /&gt;        {&lt;br /&gt;            //    http://compactprivacypolicy.org/compact_token_reference.htm&lt;br /&gt;            CompactPolicy    = &amp;quot;NON DSP COR STP COM&amp;quot;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        #region properties&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Gets or sets the javascript callback function that is&lt;br /&gt;        /// to be invoked in the resulting script output.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;value&amp;gt;The callback function name.&amp;lt;/value&amp;gt;&lt;br /&gt;        public string Callback { get; set; }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Gets or sets the compact policy values. By default the compact policy&lt;br /&gt;        /// says &amp;quot;We provide noinformation to 3rd party sources&amp;quot;.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        public string CompactPolicy { get; set; }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        #region methods&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Enables processing of the result of an action method by a&lt;br /&gt;        /// custom type that inherits from &amp;lt;see cref=&amp;quot;T:System.Web.Mvc.ActionResult&amp;quot;/&amp;gt;.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;The context within which the&lt;br /&gt;        /// result is executed.&amp;lt;/param&amp;gt;&lt;br /&gt;        public override void ExecuteResult(ControllerContext context)&lt;br /&gt;        {&lt;br /&gt;            if (context == null)&lt;br /&gt;            {&lt;br /&gt;                throw new ArgumentNullException(&amp;quot;context&amp;quot;);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            HttpResponseBase response = context.HttpContext.Response;&lt;br /&gt;&lt;br /&gt;            if (!String.IsNullOrEmpty(ContentType))&lt;br /&gt;            {&lt;br /&gt;                response.ContentType = ContentType;&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                response.ContentType = &amp;quot;application/json&amp;quot;;&lt;br /&gt;            }&lt;br /&gt;            if (ContentEncoding != null)&lt;br /&gt;            {&lt;br /&gt;                response.ContentEncoding = ContentEncoding;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            if ( string.IsNullOrEmpty( Callback ) )&lt;br /&gt;            {&lt;br /&gt;                Callback = context.HttpContext.Request.QueryString[&amp;quot;callback&amp;quot;];    &lt;br /&gt;&lt;br /&gt;                if ( string.IsNullOrEmpty( Callback ) )&lt;br /&gt;                {&lt;br /&gt;                    Callback = context.HttpContext.Request.QueryString[&amp;quot;jsoncallback&amp;quot;];    &lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            if( string.IsNullOrEmpty( CompactPolicy ) == false )&lt;br /&gt;            {&lt;br /&gt;                // TODO: uncomment when we get an IIS 7 server&lt;br /&gt;                //response.Headers.Add( &amp;quot;compact-policy&amp;quot;, CompactPolicy );&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            if (Data != null)&lt;br /&gt;            {&lt;br /&gt;                // The JavaScriptSerializer type was marked as obsolete prior to .NET Framework 3.5 SP1&lt;br /&gt;#pragma warning disable 0618&lt;br /&gt;                var serializer = new JavaScriptSerializer();&lt;br /&gt;                var ser            = serializer.Serialize(Data);&lt;br /&gt;                response.Write(Callback + &amp;quot;(&amp;quot; + ser + &amp;quot;)&amp;quot;);&lt;br /&gt;#pragma warning restore 0618&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;JsonFilterAttribute.cs:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;using System;&lt;br /&gt;using System.Web.Mvc;&lt;br /&gt;&lt;br /&gt;namespace Ucsb.Sa.Enterprise.Utility.Web.Mvc&lt;br /&gt;{&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// A Jsonp attribute to override older JsonResult objects.&lt;br /&gt;    /// &lt;br /&gt;    ///    Created by:&lt;br /&gt;    /// stimms (http://stackoverflow.com/questions/758879/asp-net-mvc-returning-jsonp)&lt;br /&gt;    /// Ranju V (http://blogorama.nerdworks.in/entry-EnablingJSONPcallsonASPNETMVC.aspx)&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    public class JsonpFilterAttribute : ActionFilterAttribute&lt;br /&gt;    {&lt;br /&gt;        public override void OnActionExecuted(ActionExecutedContext filterContext)&lt;br /&gt;        {&lt;br /&gt;            if(filterContext == null)&lt;br /&gt;                throw new ArgumentNullException(&amp;quot;filterContext&amp;quot;);&lt;br /&gt;&lt;br /&gt;            //&lt;br /&gt;            // see if this request included a &amp;quot;callback&amp;quot; querystring parameter&lt;br /&gt;            //&lt;br /&gt;            string callback = filterContext.HttpContext.Request.QueryString[&amp;quot;callback&amp;quot;];&lt;br /&gt;            if (callback != null &amp;amp;&amp;amp; callback.Length &amp;gt; 0)&lt;br /&gt;            {&lt;br /&gt;                //&lt;br /&gt;                // ensure that the result is a &amp;quot;JsonResult&amp;quot;&lt;br /&gt;                //&lt;br /&gt;                JsonResult result = filterContext.Result as JsonResult;&lt;br /&gt;                if (result == null)&lt;br /&gt;                {&lt;br /&gt;                    throw new InvalidOperationException(&amp;quot;JsonpFilterAttribute must be applied only &amp;quot; +&lt;br /&gt;                        &amp;quot;on controllers and actions that return a JsonResult object.&amp;quot;);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                filterContext.Result = new JsonpResult&lt;br /&gt;                {&lt;br /&gt;                    ContentEncoding = result.ContentEncoding,&lt;br /&gt;                    ContentType = result.ContentType,&lt;br /&gt;                    Data = result.Data,&lt;br /&gt;                    Callback = callback&lt;br /&gt;                };&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;JsonController.cs:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;using System.Text;&lt;br /&gt;using System.Web.Mvc;&lt;br /&gt;&lt;br /&gt;namespace Ucsb.Sa.Enterprise.Utility.Web.Mvc&lt;br /&gt;{&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// Controller which adds Jsonp ActionResults to the base Controller.&lt;br /&gt;    /// &lt;br /&gt;    ///    Created by:&lt;br /&gt;    /// stimms (http://stackoverflow.com/questions/758879/asp-net-mvc-returning-jsonp)&lt;br /&gt;    /// Ranju V (http://blogorama.nerdworks.in/entry-EnablingJSONPcallsonASPNETMVC.aspx)&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    public abstract class JsonpController : Controller&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Creates and returns a Jsonp result.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;data&amp;quot;&amp;gt;The data/object to serialize.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;A Jsonp ActionResult.&amp;lt;/returns&amp;gt;&lt;br /&gt;        protected internal JsonpResult Jsonp(object data)&lt;br /&gt;        {&lt;br /&gt;            return Jsonp(data, null /* contentType */);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Creates and returns a Jsonp result.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;data&amp;quot;&amp;gt;The data/object to serialize.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;behavior&amp;quot;&amp;gt;Allow Get requests.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;A Jsonp ActionResult.&amp;lt;/returns&amp;gt;&lt;br /&gt;        protected internal JsonpResult Jsonp(object data, JsonRequestBehavior behavior )&lt;br /&gt;        {&lt;br /&gt;            return Jsonp(data, null /* contentType */, behavior );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Creates and returns a Jsonp result.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;data&amp;quot;&amp;gt;The data/object to serialize.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;contentType&amp;quot;&amp;gt;The contentType to return.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;A Jsonp ActionResult.&amp;lt;/returns&amp;gt;&lt;br /&gt;        protected internal JsonpResult Jsonp(object data, string contentType)&lt;br /&gt;        {&lt;br /&gt;            return Jsonp(data, contentType, null);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Creates and returns a Jsonp result.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;data&amp;quot;&amp;gt;The data/object to serialize.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;contentType&amp;quot;&amp;gt;The contentType to return.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;behavior&amp;quot;&amp;gt;Allow Get requests.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;A Jsonp ActionResult.&amp;lt;/returns&amp;gt;&lt;br /&gt;        protected internal JsonpResult Jsonp(object data, string contentType, JsonRequestBehavior behavior)&lt;br /&gt;        {&lt;br /&gt;            return Jsonp(data, contentType, null, behavior);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Creates and returns a Jsonp result.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;data&amp;quot;&amp;gt;The data/object to serialize.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;contentType&amp;quot;&amp;gt;The contentType to return.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;contentEncoding&amp;quot;&amp;gt;The contentEncoding type.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;A Jsonp ActionResult.&amp;lt;/returns&amp;gt;&lt;br /&gt;        protected internal virtual JsonpResult Jsonp(object data, string contentType, Encoding contentEncoding)&lt;br /&gt;        {&lt;br /&gt;            return Jsonp( data, contentType, contentEncoding, JsonRequestBehavior.DenyGet );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Creates and returns a Jsonp result.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;data&amp;quot;&amp;gt;The data/object to serialize.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;contentType&amp;quot;&amp;gt;The contentType to return.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;contentEncoding&amp;quot;&amp;gt;The contentEncoding type.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;behavior&amp;quot;&amp;gt;Allow Get requests.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;A Jsonp ActionResult.&amp;lt;/returns&amp;gt;&lt;br /&gt;        protected internal virtual JsonpResult Jsonp(object data, string contentType, Encoding contentEncoding, JsonRequestBehavior behavior)&lt;br /&gt;        {&lt;br /&gt;            return new JsonpResult&lt;br /&gt;            {&lt;br /&gt;                Data = data,&lt;br /&gt;                ContentType = contentType,&lt;br /&gt;                ContentEncoding = contentEncoding,&lt;br /&gt;                JsonRequestBehavior = behavior&lt;br /&gt;            };&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I hope this helps others get around the JSONP problem until ASP.NET MVC implements a standard method for this.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-3972995568665402234?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/3972995568665402234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/using-jsonp-with-aspnet-mvc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/3972995568665402234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/3972995568665402234'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/using-jsonp-with-aspnet-mvc.html' title='Using JSONP with ASP.NET MVC'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-8161396494741132172</id><published>2009-12-17T01:11:00.001-08:00</published><updated>2009-12-17T01:17:26.443-08:00</updated><title type='text'>From Ubuntu to Windows 7</title><content type='html'>&lt;p&gt;A couple years ago I swore that I would never pay for an Operating System again. It just seemed pointless. No matter what Operating System you choose (Windows, Mac, Linux) you would always have problems. And I hated the idea that I was paying for those problems. So, I made a deal with my workplace (which is a Microsoft shop); if they provided me with an operating system for home then I would remote in when needed. This was just a polite gesture on both of our parts. I was going to remote in anyways and they knew I was going to remote in. So, they were kind enough to provide me with a Windows XP Home copy to use for remote desktoping.&lt;/p&gt;  &lt;p&gt;However, at the time, I had already switched to Ubuntu as my home environment. So, Windows XP was loaded up in a VMWare virtual machine (I have used the free version of VMWare for over 6 years and am a big supporter of their virtual software … it’s easy to use and easy to install).&lt;/p&gt;  &lt;p&gt;But, after 7+ years of using Linux/Ubuntu as my home Operating System I have switched back to Windows 7. It wasn’t an easy transition because there are a lot of command line features that I loved in Ubuntu which aren’t replicated in Windows. PowerShell (for Windows) really helps bridge the gap, but it’s not the same. The best analogy I can come up with is …&lt;/p&gt;  &lt;p&gt;* using the Linux command line is like talking to a college valedictorian. They get it right away.&lt;/p&gt;  &lt;p&gt;* using Window’s Poweshell is like talking to a high school valedictorian. They know what your talking about, but you have to be verbose.&lt;/p&gt;  &lt;p&gt;* using Window’s normal command line is like talking to a retarded (“mentally-disabled”) high schooler. It doesn’t matter how many times you try to explain it, they still won’t get it.&lt;/p&gt;  &lt;p&gt;The switch over was pretty painless. I was able to copy almost all the files I wanted to keep onto a thumb drive, because most of my work was replicated online (For the less Linux established this is a slight at Windows … Linus Torvalds, “Only wimps use tape backup: _real_ men just upload their important stuff on &lt;a href="http://en.wikipedia.org/wiki/FTP"&gt;ftp&lt;/a&gt;, and let the rest of the world mirror it”).&lt;/p&gt;  &lt;p&gt;I was able to get up and running on Windows 7 within less than an hour. So, good on ya’ Windows. The only thing that I had a problem with was rebooting the system. Apparently the Windows copy I bought did something really spectacular!!&lt;/p&gt;  &lt;p&gt;Buying a real version of Windows still seems, to me, like paying for an Operating System with problems. So, I choose the cheapest option I could find for my purposes. I wanted to remote desktop into work, and I wanted to make that remote desktop experience the best possible. Only Windows 7 Ultimate had the feature to remote desktop with multiple displays, so I bought Ultimate (a waste of money for 99% of users). But, I didn’t want to pay full price; so I bought a “System Builders” version. The system builder version comes with a couple of ridiculous stipulations which all boil down to one point: You will NOT get support from Microsoft if something goes wrong. It is about $100 cheaper to buy this version, but if something doesn’t work then you need to be really good with Google.&lt;/p&gt;  &lt;p&gt;Of course, I had a problem right off the bat. The System Builders version doesn’t overwrite the MBR. Which means, if you restart the system, it will use your old MBR and hang if that MBR doesn’t point to anything usable. Since I had Ubuntu installed before, the MBR was a GRUB loader and pointed to a non-existent partition (since I erased/overwrote all the partitions with the Windows install).&lt;/p&gt;  &lt;p&gt;If you have Linux installed on the system, your normal boot sector won’t be overwritten. That makes the “System Builders” version of Windows the perfect installer for dual-boot users. Unfortunately, I wasn’t trying to be a dual-boot user. So, after some searching on the Microsoft website I was able to find a MBR installer. The searching only took about 20 minutes (about 1/10th the amount of time it takes to solve a linux problem), so I was pretty happy with the easy install and quick fixes.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-8161396494741132172?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/8161396494741132172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/from-ubuntu-to-windows-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/8161396494741132172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/8161396494741132172'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/from-ubuntu-to-windows-7.html' title='From Ubuntu to Windows 7'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-7173034333447933068</id><published>2009-12-17T00:26:00.001-08:00</published><updated>2009-12-17T00:26:26.887-08:00</updated><title type='text'>AFTK explanation …</title><content type='html'>&lt;p&gt;So, not posting to a blog which is rarely read is not a big deal. And, I’m not going to say this was any different.&lt;/p&gt;  &lt;p&gt;I stopped posting when I found out that I had to learn SAP for a new Student Information System (SIS) at UCSB. It was supposed to take at least a year to learn SAP and another year to implement a UCSB SIS system. Fortunately, after two months we found out that all the promises that SAP gave us were wrong (the salesman lied, whats new). Their SIS system could not handle UCSB’s grading or graduation logic.&lt;/p&gt;  &lt;p&gt;Within the two months of training on SAP I did learn all that anyone really needs to know about SAP. STAY AWAY! STAY FAR AWAY! It is a mainframe system that was too big to translate into the new world; so SAP decided to replicate the mainframe environment into a pseudo virtual machine. If you want to speed things up, then add more hardware and deploy more virtual machines. That will load balance the systems. Of course, it doesn’t help solve the central issue … SAP is slow. Really slow! And, it also doesn’t help that the system is still based on a mainframe. Which means modern day web programming is like pulling teeth from a lion. Hard and your efforts usually get butchered in the process. (for you SAP developers out there, /se80 … WTF!!!)&lt;/p&gt;  &lt;p&gt;After that I started going full time on an imaging project in .NET. Our division decided to use Atalasoft’s DotNet Imaging for both the Windows and Web frameworks. It’s a pretty well developed product considering the application space. But, it’s far from “easy to use”. I have been working on the web side, and I hope to put up some posts on how to use the product with ASP.NET MVC within the next couple weeks. Atalasoft doesn’t officially support ASP.NET MVC, but they are very excited about the idea of integration; so they have provided some support during the process (the sales team seemed excited; but I dare not mention MVC within the support requests). All-in-all Atalasoft has a product which deals with a difficult area of web development and they are trying to do the best they can with the resources they have.&lt;/p&gt;  &lt;p&gt;Other than that, I’m trying to find time to develop a jQuery breadcrumb plugin (&lt;a title="http://code.google.com/p/jbreadcrumb/" href="http://code.google.com/p/jbreadcrumb/"&gt;http://code.google.com/p/jbreadcrumb/&lt;/a&gt;). I’m not finding much time to work on it … but, plugins are a step-by-step process.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-7173034333447933068?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/7173034333447933068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/aftk-explanation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/7173034333447933068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/7173034333447933068'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/12/aftk-explanation.html' title='AFTK explanation …'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-831261479786367680</id><published>2009-09-26T13:02:00.001-07:00</published><updated>2009-09-26T13:04:10.410-07:00</updated><title type='text'>Microsoft and Google CDN Response Times</title><content type='html'>&lt;p&gt;Last week &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx"&gt;Microsoft announced&lt;/a&gt; that it would be hosting some of the common javascript files used with ASP.NET applications (jQuery, Microsoft AJAX, etc). Google had been doing this for a while through both &lt;a href="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;standard CDN&lt;/a&gt; and &lt;a href="http://code.google.com/apis/ajaxlibs/"&gt;ajax library calls&lt;/a&gt;, but it was great to see Microsoft also put up a resource which hosted the MS specific javascript files that you can’t find else where.&lt;/p&gt;  &lt;p&gt;The applications that I work with are already using the Google CDN to load jQuery and jQuery-UI, but I wanted to know if there would be a benefit to switching. The most important thing for a CDN is to be fast, and Microsoft/Akamai is pretty darn fast. Below are the results of a ping test to the servers:&lt;/p&gt;  &lt;pre class="brush: xml; gutter: false; toolbar: false;"&gt;smaglio@sensei:~$ ping ajax.microsoft.com&lt;br /&gt;PING a1363.g.akamai.net (70.183.191.139) 56(84) bytes of data.&lt;br /&gt;64 bytes from a-70-183-191-139.deploy.akamaitechnologies.com (70.183.191.139): icmp_seq=1 ttl=60 time=13.8 ms&lt;br /&gt;64 bytes from a-70-183-191-139.deploy.akamaitechnologies.com (70.183.191.139): icmp_seq=2 ttl=60 time=16.1 ms&lt;br /&gt;64 bytes from a-70-183-191-139.deploy.akamaitechnologies.com (70.183.191.139): icmp_seq=3 ttl=60 time=16.5 ms&lt;br /&gt;64 bytes from a-70-183-191-139.deploy.akamaitechnologies.com (70.183.191.139): icmp_seq=4 ttl=60 time=26.7 ms&lt;br /&gt;64 bytes from a-70-183-191-139.deploy.akamaitechnologies.com (70.183.191.139): icmp_seq=5 ttl=60 time=15.2 ms&lt;br /&gt;^C&lt;br /&gt;--- a1363.g.akamai.net ping statistics ---&lt;br /&gt;5 packets transmitted, 5 received, 0% packet loss, time 4005ms&lt;br /&gt;rtt min/avg/max/mdev = 13.854/17.711/26.758/4.620 ms&lt;br /&gt;smaglio@sensei:~$ ping ajax.googleapis.com&lt;br /&gt;PING googleapis-ajax.l.google.com (209.85.225.95) 56(84) bytes of data.&lt;br /&gt;64 bytes from iy-in-f95.google.com (209.85.225.95): icmp_seq=1 ttl=55 time=73.2 ms&lt;br /&gt;64 bytes from iy-in-f95.google.com (209.85.225.95): icmp_seq=2 ttl=55 time=77.7 ms&lt;br /&gt;64 bytes from iy-in-f95.google.com (209.85.225.95): icmp_seq=3 ttl=55 time=76.2 ms&lt;br /&gt;64 bytes from iy-in-f95.google.com (209.85.225.95): icmp_seq=4 ttl=55 time=74.6 ms&lt;br /&gt;64 bytes from iy-in-f95.google.com (209.85.225.95): icmp_seq=5 ttl=55 time=71.3 ms&lt;br /&gt;64 bytes from iy-in-f95.google.com (209.85.225.95): icmp_seq=6 ttl=55 time=69.5 ms&lt;br /&gt;^C&lt;br /&gt;--- googleapis-ajax.l.google.com ping statistics ---&lt;br /&gt;6 packets transmitted, 6 received, 0% packet loss, time 5007ms&lt;br /&gt;rtt min/avg/max/mdev = 69.592/73.815/77.725/2.772 ms&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-831261479786367680?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/831261479786367680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/09/microsoft-and-google-cdn-response-times.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/831261479786367680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/831261479786367680'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/09/microsoft-and-google-cdn-response-times.html' title='Microsoft and Google CDN Response Times'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-718634289875184944</id><published>2009-06-23T07:55:00.001-07:00</published><updated>2009-06-23T08:10:44.191-07:00</updated><title type='text'>Adding Schema &amp; Sproc Prefix to ELMAH</title><content type='html'>&lt;p&gt;Background: &lt;a href="http://www.raboof.com/projects/Elmah/"&gt;ELMAH (Error Logging Modules and Handlers)&lt;/a&gt; is a great tool for any web developer that doesn’t want to go through the pain of adding in error logging to their web applications. A &lt;a href="http://dotnetslackers.com/articles/aspnet/ErrorLoggingModulesAndHandlers.aspx"&gt;great tutorial on it&lt;/a&gt; was written up by Simone Busoli.&lt;/p&gt;  &lt;p&gt;One of the features that ships with ELMAH is a database script for setting up the SQL Server table and stored procedures. And, unfortunately you can’t alter the names of the stored procedures out of the box, because the names are hardcoded in the ELMAH dll. This causes a bit of a problem with our environment and SQL Server 2008, because the script is designed for SQL Server 2000. All of the stored procedures are created under the owner [dbo].&lt;/p&gt;  &lt;p&gt;While you can setup the schema of ‘dbo’ in SQL Server 2008, it’s not the most flexible way to go. Also, using the dbo schema would enforce the rule that you must have only one ELMAH error table in the database. Which would require making a separate database for each website.&lt;/p&gt;  &lt;p&gt;This constraint didn’t work for our environment, so I went through the &lt;a href="http://code.google.com/p/elmah/source/checkout"&gt;source code&lt;/a&gt; and found that it was a pretty straight forward process to add in Schema &amp;amp; Stored Procedure Prefixes while keeping the dll backwards compatible. Since ELMAH uses Inversion of Control to make it more reusable, you only need to update one file, SqlErrorLog.cs.&lt;/p&gt;  &lt;p&gt;First you add in new properties for the Schema and SprocPrefix. And, then initialize them in the constructor:&lt;/p&gt;  &lt;pre class="c#" name="code"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// The schema name to use in place of 'dbo' on 2005/2008 Sql Server instances.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;internal virtual string Schema { get; set; }&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// The stored procedure prefix. When used this will allow multiple applications&lt;br /&gt;/// to use the same database (but, different sprocs/tables) to store exception&lt;br /&gt;/// logs.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;internal virtual string SprocPrefix { get; set; }&lt;/pre&gt;&lt;pre class="c#" name="code"&gt;public SqlErrorLog(IDictionary config)&lt;br /&gt;{&lt;br /&gt;    // ... left out for clarity&lt;br /&gt;&lt;br /&gt;    //    grab the schema if provided, else use 'dbo' as default&lt;br /&gt;    Schema        = config[&amp;quot;schema&amp;quot;] == null ? &amp;quot;dbo&amp;quot; : config[&amp;quot;schema&amp;quot;].ToString().Trim();&lt;br /&gt;&lt;br /&gt;    //    grab the stored procedure prefix if one is provided. the default value is an empty string.&lt;br /&gt;    SprocPrefix    = config[&amp;quot;sprocPrefix&amp;quot;] == null ? string.Empty : config[&amp;quot;sprocPrefix&amp;quot;].ToString().Trim();&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;After that, all that’s left is updating the private Commands classes method signatures to require the schema and sprocPrefix variables. Like so:&lt;/p&gt;&lt;pre class="c#" name="code"&gt;public static SqlCommand LogError(&lt;br /&gt;    Guid id,&lt;br /&gt;    string appName,&lt;br /&gt;    string hostName,&lt;br /&gt;    string typeName,&lt;br /&gt;    string source,&lt;br /&gt;    string message,&lt;br /&gt;    string user,&lt;br /&gt;    int statusCode,&lt;br /&gt;    DateTime time,&lt;br /&gt;    string xml,&lt;br /&gt;    string schema,&lt;br /&gt;    string sprocPrefix)&lt;br /&gt;{&lt;br /&gt;    var commandText    = string.Format( &amp;quot;[{0}].[{1}ELMAH_LogError]&amp;quot;, schema, sprocPrefix );&lt;br /&gt;    var command = new SqlCommand(commandText);&lt;br /&gt;&lt;br /&gt;    // ... left out for clarity&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;And, finally update the code which calls those methods.&lt;/p&gt;&lt;p&gt;Then you can use the ‘schema’ and ‘sprocPrefix’ attributes in the configuration file.&lt;/p&gt;&lt;pre class="c#" name="code"&gt;&amp;lt;errorLog type=&amp;quot;Elmah.SqlErrorLog, Elmah&amp;quot; connectionStringName=&amp;quot;XYZ&amp;quot; schema=&amp;quot;Ent&amp;quot; sprocPrefix=&amp;quot;WebApp1_&amp;quot; /&amp;gt;&lt;/pre&gt;&lt;p&gt;Thanks Atif Aziz for making it so easy.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-718634289875184944?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/718634289875184944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/adding-schema-sproc-prefix-to-elmah.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/718634289875184944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/718634289875184944'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/adding-schema-sproc-prefix-to-elmah.html' title='Adding Schema &amp;amp; Sproc Prefix to ELMAH'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-7499386441098046317</id><published>2009-06-16T22:55:00.001-07:00</published><updated>2009-06-17T17:27:35.937-07:00</updated><title type='text'>The error message just isn’t helpful</title><content type='html'>&lt;p&gt;&lt;strong&gt;(Heads Up: This is not my code. I’m trying to help out.)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In our systems there is a web application (not website) which has an automated Cruise Control (ccnet) build. And that ccnet build has worked for a couple of weeks until I added a&amp;#160; new webpage.&lt;/p&gt;  &lt;p&gt;Unfortunately, once I added the webpage to the build I started to receive this error&amp;#160; from the asp compiler (when I removed the webpage the error went away):&lt;/p&gt;  &lt;pre&gt;/Announcements/ArchiveFeed.aspx(2): error ASPPARSE: Could not load type 'ArchiveFeed'.&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I looked at both the aspx and aspx.cs file which created the error and could not understand why the error message was being generated:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;ArchiveFeed.aspx:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="c#" name="code"&gt;&amp;lt;?xml version='1.0' encoding = 'utf-8'?&amp;gt;&lt;br /&gt;&amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; CodeBehind=&amp;quot;ArchiveFeed.aspx.cs&amp;quot; Inherits=&amp;quot;ArchiveFeed&amp;quot; Title=&amp;quot;Announcement Archives&amp;quot; %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;rows&amp;gt;&lt;br /&gt;   &amp;lt;page&amp;gt;1&amp;lt;/page&amp;gt;&lt;br /&gt;   &amp;lt;total&amp;gt;2&amp;lt;/total&amp;gt;&lt;br /&gt;   &amp;lt;records&amp;gt;15&amp;lt;/records &amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:Repeater ID=&amp;quot;repeater1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;HeaderTemplate&amp;gt;   &lt;br /&gt;    &amp;lt;/HeaderTemplate&amp;gt;&lt;br /&gt;    &lt;br /&gt;    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;    &amp;lt;row id='&amp;lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;Id&amp;quot;) %&amp;gt;'&amp;gt;&lt;br /&gt;        &amp;lt;cell&amp;gt;&amp;lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;Id&amp;quot;) %&amp;gt;&amp;lt;/cell&amp;gt;&lt;br /&gt;        &amp;lt;cell&amp;gt;&amp;lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;Subject&amp;quot;) %&amp;gt;&amp;lt;/cell&amp;gt;&lt;br /&gt;        &amp;lt;cell&amp;gt;&amp;lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;Message&amp;quot;) %&amp;gt;&amp;lt;/cell&amp;gt;&lt;br /&gt;        &amp;lt;cell&amp;gt;&amp;lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;Editor&amp;quot;) %&amp;gt;&amp;lt;/cell&amp;gt;&lt;br /&gt;        &amp;lt;cell&amp;gt;&amp;lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;Tr&amp;quot;) %&amp;gt;&amp;lt;/cell&amp;gt;&lt;br /&gt;    &amp;lt;/row&amp;gt;&lt;br /&gt;    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;    &lt;br /&gt;    &amp;lt;FooterTemplate&amp;gt;&lt;br /&gt;    &amp;lt;/FooterTemplate&amp;gt;&lt;br /&gt;    &lt;br /&gt;&amp;lt;/asp:Repeater&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/rows&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;ArchiveFeed.aspx.cs:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="c#" name="code"&gt;using System;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using Ucsb.Sa.Registrar.Herald;&lt;br /&gt;using Ucsb.Sa.Registrar.Herald.Services;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public partial class ArchiveFeed : Page&lt;br /&gt;{&lt;br /&gt;    private AnnouncementService _servAnnounce = AppSettings.GetAnnouncementService();&lt;br /&gt;    private ArrayList list1 = new ArrayList();&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        /*if (Session[&amp;quot;validated&amp;quot;] == null || !Session[&amp;quot;validated&amp;quot;].Equals(&amp;quot;true&amp;quot;))&lt;br /&gt;        {&lt;br /&gt;            Response.Redirect(&amp;quot;Login.aspx&amp;quot;);&lt;br /&gt;        }*/&lt;br /&gt;        Response.ContentType = &amp;quot;text/xml&amp;quot;;&lt;br /&gt;        AnnouncementList aList = _servAnnounce.getAllAnnouncements();&lt;br /&gt;        for (int i = 0; i &amp;lt; aList.Announcements.Count; i++)&lt;br /&gt;            list1.Add(new ArchiveInformation(aList.Announcements[i].ID,aList.Announcements[i].Subject,aList.Announcements[i].Message,&lt;br /&gt;                                             aList.Announcements[i].Editor,aList.Announcements[i].ActiveTimeRange));&lt;br /&gt;            //lists.Add(aList.Announcements[i].ID);&lt;br /&gt;        this.repeater1.DataSource = list1;&lt;br /&gt;        this.repeater1.DataBind();&lt;br /&gt;    }&lt;br /&gt;}   &lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;After asking some of the other developers in the department about the problem, a unanimous conclusion was made: “That’s just weird”. So what the heck is going on?&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;UPDATE&lt;/b&gt;: The code behind for the page wasn't able to compile because a referenced assembly wasn't updated in the source control system. I have become too reliant on the source control system's Visual Studio integration.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-7499386441098046317?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/7499386441098046317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/error-message-just-isnt-helpful.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/7499386441098046317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/7499386441098046317'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/error-message-just-isnt-helpful.html' title='The error message just isn’t helpful'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-2884652904457364161</id><published>2009-06-15T18:17:00.001-07:00</published><updated>2009-06-22T15:21:06.693-07:00</updated><title type='text'>List of useful commands: Remote Commands</title><content type='html'>&lt;p&gt;When using &lt;a href="http://www.microsoft.com/windowsXp/using/mobility/getstarted/Remoteintro.mspx"&gt;remote desktop&lt;/a&gt; a number of problems can occur which will make your remote system unresponsive. The worst of which is a system freeze, which requires a hard boot. But, here’s a couple things to try before driving into the office. In order to use these commands you will need to remote into another system on the same network.&lt;/p&gt;  &lt;p&gt;Attempt a remote reboot of the system: shutdown –m &lt;a href="file://\\XXX.XXX.XXX.XXX"&gt;\\XXX.XXX.XXX.XXX&lt;/a&gt;&amp;#160; -r&lt;/p&gt;  &lt;p&gt;Sometimes, after attempting a remote restart the shutdown process seems to hang or become unresponsive. If that occurs, then you can use &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx"&gt;psexec&lt;/a&gt; to attempt to run remote commands: psexec &lt;a href="file://\\XXX.XXX.XXX.XXX"&gt;\\XXX.XXX.XXX.XXX&lt;/a&gt; cmd.exe&lt;/p&gt;  &lt;p&gt;Once you have a command prompt on the remote system, you can get a list of active processes using: tasklist&lt;/p&gt;  &lt;p&gt;And, you can kill a process using: taskkill /PID XXXX or taskkill /IM notepad.exe&lt;/p&gt;  &lt;p&gt;To exit psexec use Ctrl-C.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-2884652904457364161?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/2884652904457364161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/list-of-useful-commands-remote-commands.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/2884652904457364161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/2884652904457364161'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/list-of-useful-commands-remote-commands.html' title='List of useful commands: Remote Commands'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-2132619332245087955</id><published>2009-06-13T11:18:00.001-07:00</published><updated>2009-06-13T11:18:09.381-07:00</updated><title type='text'>Windows 7 RC, VS 2010 Beta &amp; SQL Server 2008 SP1</title><content type='html'>&lt;p&gt;Near the end of the VS 2010 Beta installer SQL Server Express 2008 is installed. The installer will pause for a moment and display a warning dialog stating that SQL Server has known compatibility issues with this version of Windows. An installation helper is provided which offers a solution of installing SQL Server 2008 SP1. The given link to the SP1 installer is: &lt;a title="http://www.microsoft.com/downloads/details.aspx?familyid=01AF61E6-2F63-4291-BCAD-FD500F6027FF&amp;amp;displaylang=en#filelist" href="http://www.microsoft.com/downloads/details.aspx?familyid=01AF61E6-2F63-4291-BCAD-FD500F6027FF&amp;amp;displaylang=en#filelist"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=01AF61E6-2F63-4291-BCAD-FD500F6027FF&amp;amp;displaylang=en#filelist&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Unfortunately, all of the downloads on the page are install for SQL Server Express editions, not SP1. There are links on the bottom of the page which lead to the SP1 download: &lt;a title="http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19&amp;amp;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19&amp;amp;displaylang=en&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Hopefully, this write up will clear up a little bit of the confusion. It’s also likely that a future version of the installer will include the service pack.&lt;/p&gt;  &lt;p&gt;PS. After a little bit more searching on MSDN, I ran across a much more thorough write-up by Weston Hutchins: &lt;a title="http://social.msdn.microsoft.com/Forums/en-US/setupprerelease/thread/4c740329-7366-43ca-b9f4-207a391b311b" href="http://social.msdn.microsoft.com/Forums/en-US/setupprerelease/thread/4c740329-7366-43ca-b9f4-207a391b311b"&gt;http://social.msdn.microsoft.com/Forums/en-US/setupprerelease/thread/4c740329-7366-43ca-b9f4-207a391b311b&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-2132619332245087955?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/2132619332245087955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/windows-7-rc-vs-2010-beta-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/2132619332245087955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/2132619332245087955'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/windows-7-rc-vs-2010-beta-sql-server.html' title='Windows 7 RC, VS 2010 Beta &amp;amp; SQL Server 2008 SP1'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-3555309655928270560</id><published>2009-06-01T17:29:00.001-07:00</published><updated>2009-06-01T17:46:29.432-07:00</updated><title type='text'>iPhone and Microsoft Exchange</title><content type='html'>&lt;p&gt;At work we use a Microsoft Exchange server for all email. It’s a stable email server and the Microsoft Outlook client has a really polished UI. The 3rd party extensions aren’t as mature (IMHO) as the Thunderbird extensions, but the Calendar integration is pretty top notch.&lt;/p&gt;  &lt;p&gt;I try to keep all my calendar events using the Exchange calendar system because it’s so easy to use. And I have integrated the Exchange Calendar with Google Calendar in order to have easy access to the system from home. The &lt;a href="http://www.google.com/support/calendar/bin/answer.py?hl=en&amp;amp;answer=89955"&gt;Google Calendar Sync&lt;/a&gt; service does a pretty good job of providing synchronization, but I’ve seen it miss a few appointments/meetings here and there. For the most part, it’s accurate and efficient.&lt;/p&gt;  &lt;p&gt;Recently, I got an iPhone and have been blown away by the integration and accuracy. I haven’t been using the iPhone as long as the Google Calendar Sync; so this might be a premature evaluation.&lt;/p&gt;  &lt;p&gt;However, I have found a couple of the features to be really compelling.&lt;/p&gt;  &lt;p&gt;First, the easiness of adding my email account to the iPhone was amazing. Of course I had to put in my email address &amp;amp; password. But, here was the great part: To hook up the phone to the web interface of Exchange meant 1) entering the domain name that the Exchange server was on (eg. somedomain.com) and then 2) click “Next”. The phone searched the domain network for a web access point and returned with the correct dns information (eg. webmail.somedomain.com). That was it.&lt;/p&gt;  &lt;p&gt;Second, I’ve compared the iPhone’s calendar with my Google Calendar and the iPhone caught all of the appointments/meetings which the Google Calendar missed.&lt;/p&gt;  &lt;p&gt;Third, the iPhone is actually receiving emails a few seconds before the Outlook client on my work computer is. And, the Calendar is automatically being updated when the email arrives.&lt;/p&gt;  &lt;p&gt;A Big THANK YOU to the iPhone designers for making this such an easy process!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The other phone I was considering was the &lt;a href="http://www.t-mobileg1.com/"&gt;Google phone&lt;/a&gt;. Does anyone have experience with that phone? How does the email/calendar integration on the G1 compare with the iPhone email/calendar integration?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-3555309655928270560?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/3555309655928270560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/iphone-and-microsoft-exchange.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/3555309655928270560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/3555309655928270560'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/06/iphone-and-microsoft-exchange.html' title='iPhone and Microsoft Exchange'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-431146949316186573</id><published>2009-05-06T15:42:00.001-07:00</published><updated>2009-05-06T15:50:28.857-07:00</updated><title type='text'>Render View Inline</title><content type='html'>&lt;p&gt;For one reason or another I wanted to render a view within a controller in order to add the html output to a JSON reply. This isn’t the way &lt;a href="http://www.asp.net/mvc/"&gt;ASP.NET MVC&lt;/a&gt; was designed, but it is a useful feature to add in.&lt;/p&gt; &lt;p&gt;Because ASP.NET wasn’t designed to run views from Controllers and manipulate/reuse the result after processing was finished, the ViewResult.ExecuteResult method does not return any handle to the html string produced.&lt;/p&gt; &lt;p&gt;You can get around this, by replacing the underlying HtmlTextWriter class which the ViewResult uses with a StringBuilder. Once ExecuteResult is finished, the properly formatted html will be available through the StringBuilder.&lt;/p&gt; &lt;p&gt;Here is a method which swaps in the StringBuilder and executes the View:&lt;/p&gt;&lt;pre class="c#" name="code"&gt;public static StringBuilder ExecuteResult( ViewResult view, ControllerContext context )&lt;br&gt;{&lt;br&gt;    var responseWrapper     = context.HttpContext.Response;&lt;br&gt;    var response            = ReflectionUtil.GetPrivateVariable( responseWrapper, "_httpResponse" );&lt;br&gt;    var originalWriter      = ReflectionUtil.GetPrivateVariable( response, "_writer" );&lt;br&gt;&lt;br&gt;    var builder             = new StringBuilder( 1000 );&lt;br&gt;    var writer              = new HtmlTextWriter( new StringWriter( builder ) );&lt;br&gt;&lt;br&gt;    ReflectionUtil.SetPrivateVariable( response, "_writer", writer );&lt;br&gt;    view.ExecuteResult( context );&lt;br&gt;    ReflectionUtil.SetPrivateVariable( response, "_writer", originalWriter );&lt;br&gt;    &lt;br&gt;    return builder;&lt;br&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;ReflectionUtil.SetPrivateMethod is a wrapper for some of the common reflection usages (just to save a couple of keystrokes):&lt;/p&gt;&lt;pre class="c#" name="code"&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;/// Utility containing short-cut methods for the System.Reflection namespace.&lt;br&gt;/// &amp;lt;/summary&amp;gt;&lt;br&gt;public class ReflectionUtil&lt;br&gt;{&lt;br&gt;&lt;br&gt;    /// &amp;lt;summary&amp;gt;&lt;br&gt;    /// Changes the objects internal value.&lt;br&gt;    /// &amp;lt;/summary&amp;gt;&lt;br&gt;    /// &amp;lt;param name="obj"&amp;gt;Object to alter&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;param name="variableName"&amp;gt;Private variable name&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;param name="newValue"&amp;gt;Value to change the variable to.&amp;lt;/param&amp;gt;&lt;br&gt;    public static void SetPrivateVariable(&lt;br&gt;        object        obj,&lt;br&gt;        string        variableName,&lt;br&gt;        object        newValue&lt;br&gt;    ) {&lt;br&gt;        SetInvoke(&lt;br&gt;            obj,&lt;br&gt;            variableName,&lt;br&gt;            newValue,&lt;br&gt;            BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Instance&lt;br&gt;        );&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    /// &amp;lt;summary&amp;gt;&lt;br&gt;    /// Retrieves a private variables value using reflection.&lt;br&gt;    /// &amp;lt;/summary&amp;gt;&lt;br&gt;    /// &amp;lt;param name="obj"&amp;gt;Object to retrieve the value from.&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;param name="variableName"&amp;gt;The variable to read.&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;returns&amp;gt;The variable's contents as an object.&amp;lt;/returns&amp;gt;&lt;br&gt;    public static object GetPrivateVariable(&lt;br&gt;        object        obj,&lt;br&gt;        string        variableName&lt;br&gt;    ) {&lt;br&gt;        FieldInfo    info    = obj.GetType().GetField(&lt;br&gt;            variableName,&lt;br&gt;            BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance&lt;br&gt;        );&lt;br&gt;&lt;br&gt;        return info.GetValue( obj );&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    /// &amp;lt;summary&amp;gt;&lt;br&gt;    /// Changes the objects internal value.&lt;br&gt;    /// &amp;lt;/summary&amp;gt;&lt;br&gt;    /// &amp;lt;param name="obj"&amp;gt;Object to alter&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;param name="variableName"&amp;gt;Private variable name&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;param name="newValue"&amp;gt;Value to change the variable to.&amp;lt;/param&amp;gt;&lt;br&gt;    public static void SetPrivateProperty(&lt;br&gt;        object        obj,&lt;br&gt;        string        variableName,&lt;br&gt;        object        newValue&lt;br&gt;    ) {&lt;br&gt;        SetInvoke(&lt;br&gt;            obj,&lt;br&gt;            variableName,&lt;br&gt;            newValue,&lt;br&gt;            BindingFlags.SetProperty | BindingFlags.NonPublic | BindingFlags.Instance&lt;br&gt;        );&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    /// &amp;lt;summary&amp;gt;&lt;br&gt;    /// Changes the objects internal value.&lt;br&gt;    /// &amp;lt;/summary&amp;gt;&lt;br&gt;    /// &amp;lt;param name="obj"&amp;gt;Object to alter&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;param name="variableName"&amp;gt;Private variable name&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;param name="newValue"&amp;gt;Value to change the variable to.&amp;lt;/param&amp;gt;&lt;br&gt;    /// &amp;lt;param name="bindingFlags"&amp;gt;The binding flags to look through.&amp;lt;/param&amp;gt;&lt;br&gt;    public static void SetInvoke(&lt;br&gt;        object          obj,&lt;br&gt;        string          variableName,&lt;br&gt;        object          newValue,&lt;br&gt;        BindingFlags    bindingFlags&lt;br&gt;    ) {&lt;br&gt;        var t                = obj.GetType();&lt;br&gt;        var lastException    = new Exception( "NULL" );&lt;br&gt;&lt;br&gt;        while( t != null ) {&lt;br&gt;            try {&lt;br&gt;                t.InvokeMember( variableName, bindingFlags, null, obj, new [] { newValue } );&lt;br&gt;                return;&lt;br&gt;            } catch( Exception e ) {&lt;br&gt;                lastException    = e;&lt;br&gt;                t    = t.BaseType;&lt;br&gt;            }&lt;br&gt;        }&lt;br&gt;        &lt;br&gt;        if( lastException.Message != "NULL" )    throw lastException;&lt;br&gt;    }&lt;br&gt;&lt;br&gt;}&lt;/pre&gt;&lt;p&gt;UPDATE: I ran into a &lt;a href="http://mikehadlow.blogspot.com/2008/06/mvc-framework-capturing-output-of-view_05.html"&gt;posting by Mike Hadlow&lt;/a&gt; which was trying the same thing, but ran into a snag with the Response Headers being marked as written after ExecuteResult completed. He also has a way to get around the problem.&lt;/p&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e9a42ad2-b0f6-474a-a8e9-9cb7d3578bc7" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/ASP.NET+MVC" rel="tag"&gt;ASP.NET MVC&lt;/a&gt;,&lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Reflection" rel="tag"&gt;Reflection&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-431146949316186573?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/431146949316186573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/05/render-view-inline.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/431146949316186573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/431146949316186573'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/05/render-view-inline.html' title='Render View Inline'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-7699921127741012482</id><published>2009-04-30T15:44:00.001-07:00</published><updated>2009-05-06T12:17:23.215-07:00</updated><title type='text'>MVC Static Content DNS Helper</title><content type='html'>&lt;p&gt;A website I was working on needed a way to include references to static content (images/css/js) which could dynamically point to the correct server for the build environment (dev,test,prod). This was accomplished by creating extension methods for the HtmlHelper.&lt;/p&gt;  &lt;p&gt;I recently wrote about using a static content website on a &lt;a href="http://stevenmaglio.blogspot.com/2009/04/development-guide-ucsb-static-content.html"&gt;previous post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;We already had an enumeration setup to describe the environment (listed below the post). We just needed a way to parse string values and add the dns name. To do this, we made a class for ASP.NET 2.0 websites and for ASP.NET MVC websites. It also needed to add the “.min.js” extension for production javascript.&lt;/p&gt;  &lt;p&gt;ASP.NET 2.0:&lt;/p&gt;  &lt;pre class="c#" name="code"&gt;using System.Web;&lt;br /&gt;using Ucsb.Sa.Registrar.Util;&lt;br /&gt;&lt;br /&gt;namespace Ucsb.Sa.Enterprise.Utility.Web&lt;br /&gt;{&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// Static content extension methods for &amp;lt;see cref=&amp;quot;HtmlHelper&amp;quot; /&amp;gt;. This file requires that the web&lt;br /&gt;    /// application contains a static AppSettings file with property BuildEnvironment.&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    public static class StaticContentExtensions&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        #region variables&lt;br /&gt;&lt;br /&gt;        private const string BaseImageUrlFormat        = &amp;quot;{0}://static.{1}sa.ucsb.edu/{2}&amp;quot;;&lt;br /&gt;        private const string BasePlaceholder        = &amp;quot;~&amp;quot;;&lt;br /&gt;        private const string Image                    = &amp;quot;images&amp;quot;;&lt;br /&gt;        private const string Css                    = &amp;quot;css&amp;quot;;&lt;br /&gt;        private const string Js                        = &amp;quot;js&amp;quot;;&lt;br /&gt;        private const string JQuery                    = &amp;quot;js/jquery&amp;quot;;&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        #region properties&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Gets and Sets the &amp;lt;see cref=&amp;quot;BuildEnvironmentType&amp;quot; /&amp;gt; for the application. This&lt;br /&gt;        /// should be set before the first call to these extension methods.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        public static BuildEnvironmentType BuildEnvironment { get; set; }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// http or https&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        public static string Scheme&lt;br /&gt;        {&lt;br /&gt;            get { return HttpContext.Current.Request.Url.Scheme; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        #region public methods&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Converts an ASP url (eg. &amp;amp;quot;~/insideSa/bottom_header.jpg&amp;amp;quot;)&lt;br /&gt;        /// into a full url (eg. &amp;amp;quot;http://static.dev.sa.ucsb.edu/images/insideSa/bottom_header.jpg&amp;amp;quot;).&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;partialUrl&amp;quot;&amp;gt;The folder and file name under the static images directory.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The full path to the static website with the sub-folder and file name appended.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetImageUrl( string partialUrl )&lt;br /&gt;        {&lt;br /&gt;            return GetUrl( partialUrl, Image );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Converts an ASP url (eg. &amp;amp;quot;~/insideSa/site.css&amp;amp;quot;)&lt;br /&gt;        /// into a full url (eg. &amp;amp;quot;http://static.dev.sa.ucsb.edu/images/insideSa/site.css&amp;amp;quot;).&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;partialUrl&amp;quot;&amp;gt;The folder and file name under the static images directory.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The full path to the static website with the sub-folder and file name appended.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetCssUrl( string partialUrl )&lt;br /&gt;        {&lt;br /&gt;            return GetUrl( partialUrl, Css );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Converts an ASP url (eg. &amp;amp;quot;~/insideSa/jquery.js&amp;amp;quot;)&lt;br /&gt;        /// into a full url (eg. &amp;amp;quot;http://static.dev.sa.ucsb.edu/images/insideSa/jquery.js&amp;amp;quot;).&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;partialUrl&amp;quot;&amp;gt;The folder and file name under the static images directory.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The full path to the static website with the sub-folder and file name appended.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetJsUrl( string partialUrl )&lt;br /&gt;        {&lt;br /&gt;            var url    = GetUrl( partialUrl, Js );&lt;br /&gt;            return RewriteForMinJs( url );&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Converts an ASP url (eg. &amp;amp;quot;~/insideSa/jquery.js&amp;amp;quot;)&lt;br /&gt;        /// into a full url (eg. &amp;amp;quot;http://static.dev.sa.ucsb.edu/images/insideSa/jquery.js&amp;amp;quot;).&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;partialUrl&amp;quot;&amp;gt;The folder and file name under the static images directory.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The full path to the static website with the sub-folder and file name appended.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetJQueryUrl( string partialUrl )&lt;br /&gt;        {&lt;br /&gt;            var url    = GetUrl( partialUrl, JQuery );&lt;br /&gt;            return RewriteForMinJs( url );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Creates the javascript code to load javascript libraries from google.&lt;br /&gt;        /// This will ensure that the uncompressed version of the code is loaded on the developer&lt;br /&gt;        /// systems.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;package&amp;quot;&amp;gt;The name of the javascript library to load.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;version&amp;quot;&amp;gt;The version number to retrieve.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The string to be injected into a &amp;amp;lt;script&amp;amp;gt; section.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetGoogleLoad( string package, string version )&lt;br /&gt;        {&lt;br /&gt;            const string format                = &amp;quot;google.load('{0}', '{1}'{2}&amp;quot;;&lt;br /&gt;            const string compressed            = &amp;quot;);&amp;quot;;&lt;br /&gt;            const string uncompressed        = &amp;quot;, {uncompressed:true});&amp;quot;;&lt;br /&gt;            &lt;br /&gt;            return string.Format(&lt;br /&gt;                format,&lt;br /&gt;                package,&lt;br /&gt;                version,&lt;br /&gt;                BuildEnvironment == BuildEnvironmentType.Local ? uncompressed : compressed&lt;br /&gt;            );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        #region private methods&lt;br /&gt;&lt;br /&gt;        private static string GetUrl( string partialUrl, string subDirectory )&lt;br /&gt;        {&lt;br /&gt;            var baseUrl    = string.Format( BaseImageUrlFormat, Scheme, GetEnvironmentString(), subDirectory );&lt;br /&gt;            return partialUrl.Replace( BasePlaceholder, baseUrl );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private static string GetEnvironmentString()&lt;br /&gt;        {&lt;br /&gt;            var env        = string.Empty;    // default value for pilot and production&lt;br /&gt;&lt;br /&gt;            switch( BuildEnvironment )&lt;br /&gt;            {&lt;br /&gt;                case BuildEnvironmentType.Local:&lt;br /&gt;                case BuildEnvironmentType.Development:&lt;br /&gt;                case BuildEnvironmentType.Integration:&lt;br /&gt;                    env    = &amp;quot;dev.&amp;quot;;&lt;br /&gt;                    break;&lt;br /&gt;&lt;br /&gt;                case BuildEnvironmentType.Test:&lt;br /&gt;                    env    = &amp;quot;test.&amp;quot;;&lt;br /&gt;                    break;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return env;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private static string RewriteForMinJs( string url )&lt;br /&gt;        {&lt;br /&gt;            if( BuildEnvironment != BuildEnvironmentType.Production )    return url;&lt;br /&gt;            if( string.IsNullOrEmpty( url ) )    return url;&lt;br /&gt;&lt;br /&gt;            var len            = url.Length;&lt;br /&gt;            if( len &amp;lt; 3 )    return url;&lt;br /&gt;&lt;br /&gt;            const string ext    = &amp;quot;.js&amp;quot;;        &lt;br /&gt;            if( url.Substring( len - 3 ) != ext )    return url;&lt;br /&gt;&lt;br /&gt;            const string minExt    = &amp;quot;.min.js&amp;quot;;&lt;br /&gt;            if( url.Substring( len - 7 ) == minExt )    return url;&lt;br /&gt;&lt;br /&gt;            const string format    = &amp;quot;{0}.min.js&amp;quot;;&lt;br /&gt;            return string.Format( format, url.Substring( 0, len - 3 ) );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And the corresponding ASP.NET MVC wrapper:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="c#" name="code"&gt;using System.Web.Mvc;&lt;br /&gt;using Ucsb.Sa.Registrar.Util;&lt;br /&gt;&lt;br /&gt;namespace Ucsb.Sa.Enterprise.Utility.Web.Mvc&lt;br /&gt;{&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// Static content extension methods for &amp;lt;see cref=&amp;quot;HtmlHelper&amp;quot; /&amp;gt;. This file requires that the web&lt;br /&gt;    /// application contains a static AppSettings file with property BuildEnvironment.&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    public static class HtmlHelperStaticContentExtensions&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        #region properties&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Gets and Sets the &amp;lt;see cref=&amp;quot;BuildEnvironmentType&amp;quot; /&amp;gt; for the application. This&lt;br /&gt;        /// should be set before the first call to these extension methods.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        public static BuildEnvironmentType BuildEnvironment&lt;br /&gt;        {&lt;br /&gt;            get { return StaticContentExtensions.BuildEnvironment; }&lt;br /&gt;            set { StaticContentExtensions.BuildEnvironment = value; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        #region public methods&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Converts an ASP url (eg. &amp;amp;quot;~/insideSa/bottom_header.jpg&amp;amp;quot;)&lt;br /&gt;        /// into a full url (eg. &amp;amp;quot;http://static.dev.sa.ucsb.edu/images/insideSa/bottom_header.jpg&amp;amp;quot;).&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;html&amp;quot;&amp;gt;The object to add this extension method to.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;partialUrl&amp;quot;&amp;gt;The folder and file name under the static images directory.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The full path to the static website with the sub-folder and file name appended.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetImageUrl( this HtmlHelper html, string partialUrl )&lt;br /&gt;        {&lt;br /&gt;            return StaticContentExtensions.GetImageUrl( partialUrl );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Converts an ASP url (eg. &amp;amp;quot;~/insideSa/site.css&amp;amp;quot;)&lt;br /&gt;        /// into a full url (eg. &amp;amp;quot;http://static.dev.sa.ucsb.edu/images/insideSa/site.css&amp;amp;quot;).&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;html&amp;quot;&amp;gt;The object to add this extension method to.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;partialUrl&amp;quot;&amp;gt;The folder and file name under the static images directory.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The full path to the static website with the sub-folder and file name appended.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetCssUrl( this HtmlHelper html, string partialUrl )&lt;br /&gt;        {&lt;br /&gt;            return StaticContentExtensions.GetCssUrl( partialUrl );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Converts an ASP url (eg. &amp;amp;quot;~/insideSa/jquery.js&amp;amp;quot;)&lt;br /&gt;        /// into a full url (eg. &amp;amp;quot;http://static.dev.sa.ucsb.edu/images/insideSa/jquery.js&amp;amp;quot;).&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;html&amp;quot;&amp;gt;The object to add this extension method to.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;partialUrl&amp;quot;&amp;gt;The folder and file name under the static images directory.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The full path to the static website with the sub-folder and file name appended.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetJsUrl( this HtmlHelper html, string partialUrl )&lt;br /&gt;        {&lt;br /&gt;            return StaticContentExtensions.GetJsUrl( partialUrl );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Converts an ASP url (eg. &amp;amp;quot;~/insideSa/jquery.js&amp;amp;quot;)&lt;br /&gt;        /// into a full url (eg. &amp;amp;quot;http://static.dev.sa.ucsb.edu/images/insideSa/jquery.js&amp;amp;quot;).&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;html&amp;quot;&amp;gt;The object to add this extension method to.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;partialUrl&amp;quot;&amp;gt;The folder and file name under the static images directory.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The full path to the static website with the sub-folder and file name appended.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetJQueryUrl( this HtmlHelper html, string partialUrl )&lt;br /&gt;        {&lt;br /&gt;            return StaticContentExtensions.GetJQueryUrl( partialUrl );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Creates the javascript code to load javascript libraries from google.&lt;br /&gt;        /// This will ensure that the uncompressed version of the code is loaded on the developer&lt;br /&gt;        /// systems.&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;html&amp;quot;&amp;gt;The object to add this extension method to.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;package&amp;quot;&amp;gt;The name of the javascript library to load.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;version&amp;quot;&amp;gt;The version number to retrieve.&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;The string to be injected into a &amp;amp;lt;script&amp;amp;gt; section.&amp;lt;/returns&amp;gt;&lt;br /&gt;        public static string GetGoogleLoad( this HtmlHelper html, string package, string version )&lt;br /&gt;        {&lt;br /&gt;            return StaticContentExtensions.GetGoogleLoad( package, version );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then we used the static classes in a PartialView for rendering:&lt;br /&gt;&lt;br /&gt;&lt;pre class="c#" name="code"&gt;&amp;lt;%@ Import Namespace=&amp;quot;Ucsb.Sa.Enterprise.Utility.Web.Mvc&amp;quot;%&amp;gt;&lt;br /&gt;&amp;lt;%@ Control Language=&amp;quot;C#&amp;quot; Inherits=&amp;quot;System.Web.Mvc.ViewUserControl&amp;quot; %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetCssUrl( &amp;quot;~/reset.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetCssUrl( &amp;quot;~/blueprint/0_8/ie.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetCssUrl( &amp;quot;~/blueprint/0_8/screen.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetCssUrl( &amp;quot;~/blueprint/0_8/print.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;print&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetJQueryUrl( &amp;quot;~/1_3_2/themes/ucsb/ui.base.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetJQueryUrl( &amp;quot;~/1_3_2/themes/ucsb/jquery-ui-1.7.1.custom.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetJQueryUrl( &amp;quot;~/dataTables-1_4/css/datatables.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetJQueryUrl( &amp;quot;~/mbMenu-2_2/css/menu.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;&amp;lt;%= Html.GetCssUrl( &amp;quot;~/InsideSa/InsideSaLayout-0.0.0.1.css&amp;quot; ) %&amp;gt;&amp;quot; rel=&amp;quot;Stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Which generated html that looked like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="html" name="code"&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/css/reset.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/css/blueprint/0_8/ie.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/css/blueprint/0_8/screen.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/css/blueprint/0_8/print.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;print&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/js/jquery/1_3_2/themes/ucsb/ui.base.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/js/jquery/1_3_2/themes/ucsb/jquery-ui-1.7.1.custom.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/js/jquery/dataTables-1_4/css/datatables.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/js/jquery/mbMenu-2_2/css/menu.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;quot;http://static.dev.sa.ucsb.edu/css/insideSa/InsideSaLayout-0.0.0.1.css&amp;quot; rel=&amp;quot;Stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here is the code for the environment variables:&lt;br /&gt;&lt;br /&gt;&lt;pre class="c#" name="code"&gt;namespace Ucsb.Sa.Registrar.Util&lt;br /&gt;{&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// Enumeration for each build environment. eg. Development, Test, etc.&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    public enum BuildEnvironmentType&lt;br /&gt;    {&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// local, localhost&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        Local,&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// dev, development&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        Development,&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// int, integration&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        Integration,&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// test, qa, quality assurance&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        Test,&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// pilot&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        Pilot,&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// prod, production&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        Production&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="c#" name="code"&gt;using System;&lt;br /&gt;&lt;br /&gt;namespace Ucsb.Sa.Registrar.Util&lt;br /&gt;{&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// Attempts to parse string values to BuildEnvironmentType Enumerations.&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    public static class BuildEnvironmentTypeParser&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// &amp;lt;para&amp;gt;&lt;br /&gt;        /// Parses a string value into the corresponding environment type. Some partial and exact matches can be parsed.&lt;br /&gt;        /// &amp;lt;/para&amp;gt;&lt;br /&gt;        /// &amp;lt;para&amp;gt;ie. Development, dev, prod, test, Production, etc.&amp;lt;/para&amp;gt;&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;environmentName&amp;quot;&amp;gt;string to parse&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;returns&amp;gt;BuildEnvironmentType from parsed string.&amp;lt;/returns&amp;gt;&lt;br /&gt;        /// &amp;lt;exception cref=&amp;quot;ArgumentException&amp;quot;&amp;gt;If the argument is unknown.&amp;lt;/exception&amp;gt;&lt;br /&gt;        public static BuildEnvironmentType Parse( string environmentName ) {&lt;br /&gt;            if( string.IsNullOrEmpty( environmentName ) )&lt;br /&gt;                throw new ArgumentException( &amp;quot;Argument environmentName was null or empty.&amp;quot; );&lt;br /&gt;&lt;br /&gt;            switch( environmentName.ToLower().Trim() ) {&lt;br /&gt;                case &amp;quot;local&amp;quot;: case &amp;quot;localhost&amp;quot;:&lt;br /&gt;                    return BuildEnvironmentType.Local;&lt;br /&gt;&lt;br /&gt;                case &amp;quot;dev&amp;quot;: case &amp;quot;development&amp;quot;:&lt;br /&gt;                    return    BuildEnvironmentType.Development;&lt;br /&gt;&lt;br /&gt;                case &amp;quot;int&amp;quot;: case &amp;quot;integration&amp;quot;:&lt;br /&gt;                    return BuildEnvironmentType.Integration;&lt;br /&gt;&lt;br /&gt;                case &amp;quot;qa&amp;quot;: case &amp;quot;quality assurance&amp;quot;: case &amp;quot;test&amp;quot;:&lt;br /&gt;                    return BuildEnvironmentType.Test;&lt;br /&gt;&lt;br /&gt;                case &amp;quot;pilot&amp;quot;:&lt;br /&gt;                    return BuildEnvironmentType.Pilot;&lt;br /&gt;&lt;br /&gt;                case &amp;quot;prod&amp;quot;: case &amp;quot;production&amp;quot;:&lt;br /&gt;                    return BuildEnvironmentType.Production;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            throw new ArgumentException( &amp;quot;Argument environment name, &amp;quot; + environmentName + &amp;quot;, is of an unknown type.&amp;quot; );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-7699921127741012482?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/7699921127741012482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/04/mvc-static-content-dns-helper.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/7699921127741012482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/7699921127741012482'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/04/mvc-static-content-dns-helper.html' title='MVC Static Content DNS Helper'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-405140909142771173</id><published>2009-04-30T14:13:00.001-07:00</published><updated>2009-05-11T19:27:26.267-07:00</updated><title type='text'>Development Guide: UCSB static content website</title><content type='html'>&lt;p&gt;(This entry has to do with my personal opinion about the way a static website should be built at UCSB and does not reflect the opinions of UCSB)&lt;/p&gt;  &lt;p&gt;A static content website at UCSB would help with performance for a couple of the “high visibility” websites. But, it is not required. A couple of reasons why to use a static content website are described by &lt;a href="http://developer.yahoo.com/yslow/"&gt;YSlow&lt;/a&gt; (a plugin for Firefox): &lt;a title="http://developer.yahoo.com/performance/rules.htm" href="http://developer.yahoo.com/performance/rules.htm"&gt;http://developer.yahoo.com/performance/rules.htm&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;At UCSB we should/will be creating a static content website for a couple more reasons:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;We copy a lot of static content into multiple of our websites (mostly for MasterPages). This causes:      &lt;ol&gt;       &lt;li&gt;Duplicate content in the source control system. &lt;/li&gt;        &lt;li&gt;Maintenance issues when updating websites. &lt;/li&gt;        &lt;li&gt;Excessive copy times when deploying websites (well, this may not be a very big issue). &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;A common infrastructure to look for images that are copyrighted/available for use on SA websites. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;It seems that there is a need for all the developers to be on the same page when using a communal share for website static content. And in that vein here are a few Development Guidelines.&lt;/p&gt;  &lt;p&gt;Development Guidelines:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;The static content website urls are at:      &lt;ol&gt;       &lt;li&gt;Dev: &lt;a href="http://static.dev.sa.ucsb.edu/"&gt;http://static.dev.sa.ucsb.edu/&lt;/a&gt; (only available within the SA network) &lt;/li&gt;        &lt;li&gt;QA/Test: &lt;a href="http://static.test.sa.ucsb.edu/"&gt;http://static.test.sa.ucsb.edu/&lt;/a&gt; (only available to UCSB IPs) &lt;/li&gt;        &lt;li&gt;Prod: &lt;a href="http://static.sa.ucsb.edu/"&gt;http://static.sa.ucsb.edu/&lt;/a&gt; (public) &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;The base folder (/) should have sub-directories for common groupings. A few upfront common groupings are:      &lt;ol&gt;       &lt;li&gt;js &lt;/li&gt;        &lt;li&gt;css &lt;/li&gt;        &lt;li&gt;images &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;Any commonly used js/css/images should be kept under the appropriate subfolder. &lt;/li&gt;    &lt;li&gt;Any project specific js/css/images should be kept under a subfolder for the application.      &lt;ol&gt;       &lt;li&gt;Examples: js/InsideSa, css/AAA &lt;/li&gt;        &lt;li&gt;If the website name is already taken, please use a new and appropriate name which describes the website the content is for. No restrictions, just don’t duplicate. &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;For third party components (eg: jquery) place a parent directory under the appropriate top directory (eg: js/jquery), but then place version directories underneath it.      &lt;ol&gt;       &lt;li&gt;js/jquery/1_2_6 &lt;/li&gt;        &lt;li&gt;js/jquery/1_3_2 &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;For third party components to third party compents (eg: jqGrid) place a parent directory under appropriate third party diretory (eg: js/jquery/jqGrid), but then place version directories underneath it.      &lt;ol&gt;       &lt;li&gt;js/jquery/jqGrid/1_4_3 &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;Never allow dots (.) in a directory name before the static content. I haven’t found any official documentation on it, but it seems like IIS will stop looking for sub-directories once the first dot is found.      &lt;ol&gt;       &lt;li&gt;For Example: If you have /js/jquery/1.2.6/jquery-1.2.6-min.js, then IIS will return a “404 File Not Found” error message for file “1.2.6”; because it considers the first dot name (1.2.6: a directory) to be the name of the file. &lt;/li&gt;        &lt;li&gt;Please use underscores (_) in place of dots in directory names. &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;When putting content into the static website always add a Version Stamp to the filename.      &lt;ol&gt;       &lt;li&gt;CSS:          &lt;ol&gt;           &lt;li&gt;Use a version number.              &lt;ol&gt;               &lt;li&gt;Please use the same version number of your website update as the filename addition. For example: css/insideSa/InsideSaLayout-0.0.0.1.css &lt;/li&gt;                &lt;li&gt;** alternative suggestion &lt;/li&gt;             &lt;/ol&gt;           &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;        &lt;li&gt;Javascript:          &lt;ol&gt;           &lt;li&gt;Use a version number.              &lt;ol&gt;               &lt;li&gt;Please use the same version number of your website update as the filename addition. For example: js/InsideSa/insideSa.menu-0.0.0.1.js &lt;/li&gt;                &lt;li&gt;** alternative suggestion &lt;/li&gt;             &lt;/ol&gt;           &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;        &lt;li&gt;Images:          &lt;ol&gt;           &lt;li&gt;Use a date/time stamp.              &lt;ol&gt;               &lt;li&gt;Use the format &amp;lt;image name&amp;gt;_yyyyMMddHHmm.&amp;lt;ext&amp;gt;. For example: images/InsideSa/background_200903260203.jpg &lt;/li&gt;                &lt;li&gt;A date/time is used because multiple images with the same name can be created during development. &lt;/li&gt;             &lt;/ol&gt;           &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;Because versioning is done in the filename, you don’t have to delete any files. Please don’t delete any files in the “common area” of the folders. The project specific folders can have files deleted if the developer(s) feel it’s okay; but we strongly suggest you don’t. Just incase some unknown project is referencing the static content.      &lt;ol&gt;       &lt;li&gt;Don’t worry about the disk space, it really shouldn’t eat up too much room. And if it becomes a problem we’ll work with the systems team to come up with a good solution. &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;Javascript files should have a development version and a minified version (for production).      &lt;ol&gt;       &lt;li&gt;The development (human readable) version should be formatted like the example in section 8.2. &lt;/li&gt;        &lt;li&gt;The minified version should have the same format as section 8.2 but with the extension .min.js.          &lt;ol&gt;           &lt;li&gt;This means that sometimes you will have to change the names of javscript files you download. For example, Microsoft uses .js for the minified version and .debug.js for the development version. &lt;/li&gt;            &lt;li&gt;You can use &lt;a href="http://www.crockford.com/javascript/jsmin.html"&gt;jsmin.exe&lt;/a&gt; to minify your javascript files after development has finished. &lt;/li&gt;            &lt;li&gt;Before and after you use jsmin.exe you should run your file through &lt;a href="http://www.jslint.com/"&gt;jslint&lt;/a&gt;. jslint has a &lt;a href="http://widgets.yahoo.com/widgets/jslint-1"&gt;yahoo widget for it&lt;/a&gt;. If anyone knows of a google gadget for it, let me know. Or even a command line version, so we can add it to an automated build script. &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;        &lt;li&gt;Mozilla has a great &lt;a href="https://developer.mozilla.org/en/JavaScript"&gt;list of links for standard javascript tools&lt;/a&gt;. &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;New Common sub-groupings do not need to be vetted (aka, submitted for approval), just make sure that there is no appropriate sub-directory already in existence.      &lt;ol&gt;       &lt;li&gt;For example: RadControls. They require that the base sub-directory be the root for all js/css/images used within their Q3 2006 dll. (This has not been done yet, because RadControls integration with MVC is not “great” yet.)          &lt;ol&gt;           &lt;li&gt;Sidenote to Telerik: We really liked your Blue theme from your 2006 components. But, those Blue themes were not added to your dll’s when you started compiling your resources into them. Which makes it difficult to easily upgrade from your website based components to your web application based dlls. =( &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;The dev area will be hooked up to the source control system. &lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;The dev area will be automatically updated into the source control system on Friday. &lt;/li&gt;      &lt;li&gt;Please update your changes into the source control system before Friday when you see fit. &lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;(UPDATE) Websites which are SSL encrypted must retrieve content through an SSL request.&lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;This is due an error message which only occurs on IE. The problem has been reported multiple times (&lt;a href="http://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=387991"&gt;387991&lt;/a&gt;,&lt;a href="http://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=387991"&gt;388636&lt;/a&gt;), but the people who report it don’t suggest removing the warning. (Firefox, Safari, Opera, and Chrome do not have an error/warning message).&lt;/li&gt;      &lt;li&gt;When the IE feedback stops giving me an error message after I sign in, I will add a “feedback” post which requests that the feature be dropped. The link to that “feedback” post will be attached here, so others may second the feature drop. (IE Team: please stop producing this error/warning message; its so unnecessary).&lt;/li&gt;   &lt;/ol&gt; &lt;/ol&gt;  &lt;p&gt;** alternative suggestion: Add version subdirectories for our applications. It can simplify things for the program. But it does complicate maintenance for the developer. Not much though. Please, ask for this if you think it will be less maintenance.&lt;/p&gt;  &lt;p&gt;Remember: This can always be updated. And as things change this should be updated.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:fa78c1d6-0c49-4712-bb46-5a369a0dbc0b" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/UCSB" rel="tag"&gt;UCSB&lt;/a&gt;,&lt;a href="http://technorati.com/tags/staticcontent" rel="tag"&gt;staticcontent&lt;/a&gt;,&lt;a href="http://technorati.com/tags/javascript" rel="tag"&gt;javascript&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-405140909142771173?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/405140909142771173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/04/development-guide-ucsb-static-content.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/405140909142771173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/405140909142771173'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/04/development-guide-ucsb-static-content.html' title='Development Guide: UCSB static content website'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-5279072761719893314</id><published>2009-04-25T10:26:00.001-07:00</published><updated>2009-04-27T10:33:27.525-07:00</updated><title type='text'>SiteMapProvider Exception Crashes the Website</title><content type='html'>&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I’m getting this error message from Visual Studio (The debugger cannot continue running the process. Process was terminated.):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://farm4.static.flickr.com/3308/3473982428_25349355b2.jpg?v=0"&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://farm4.static.flickr.com/3308/3473982428_25349355b2.jpg?v=0" width="244" height="68" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The error message is appearing when debugging a &lt;a href="http://www.asp.net/mvc/"&gt;ASP.NET MVC&lt;/a&gt; application in &lt;a href="http://www.asp.net/mvc/"&gt;Visual Studio&lt;/a&gt; 2008. The lines of code which are being executed at taking a object tree and converting it to populate a &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.sitemapprovider.aspx"&gt;SiteMapProvider&lt;/a&gt;. The error is occuring when stepping from line 10 to line 16. Line 16 is highlighted when error occurs:&lt;/p&gt;  &lt;p&gt;Code Snippet 1 (CS1)&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; InsideSaSiteMapNode CreateMvcNode( InsideSaSiteMapNodeDTO dto )&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     var node                = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; InsideSaSiteMapIntegrationNode( _Provider, dto.Href );&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     node.Href               = dto.Href;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     node.Title              = dto.Title;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     node.JavascriptAction   = dto.JavascriptAction;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     node.IconFilename       = dto.IconFilename;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     node.Target             = dto.Target;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt;( var child &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; dto.ChildNodes )&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;         var childNode    = CreateMvcNode( child );&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;         node.ChildNodes.Add( childNode );&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; node;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;As a bonus, the “Process” being referenced in the error message is the ASP.NET Development Server which is running the website. So, the website crashes.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Analysis&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The error first started when I added a line of to the SiteMapProvider method, GetChildNodes. The new code is on line 11 (commented out).&lt;/p&gt;&lt;p&gt;CS2&lt;/p&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// When overridden in a derived class, retrieves the child nodes of a specific &amp;lt;see cref=&amp;quot;T:System.Web.SiteMapNode&amp;quot;/&amp;gt;.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// A read-only &amp;lt;see cref=&amp;quot;T:System.Web.SiteMapNodeCollection&amp;quot;/&amp;gt; that contains the immediate child nodes of the specified &amp;lt;see cref=&amp;quot;T:System.Web.SiteMapNode&amp;quot;/&amp;gt;; otherwise, null or an empty collection, if no child nodes exist.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;node&amp;quot;&amp;gt;The &amp;lt;see cref=&amp;quot;T:System.Web.SiteMapNode&amp;quot;/&amp;gt; for which to retrieve all child nodes. &lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; SiteMapNodeCollection GetChildNodes( SiteMapNode node )&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//return node.ChildNodes;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;I realize that your not supposed to use the incoming node to return the child values. But, that line of code has not been called yet in the program. The error occurs in line CS1:16. The value being returned was made by a call from CS1:12; which might mean that CS1:13 is “pre-executed” when the return value is known. The frustration really lies in the idea that node.ChildNodes (which returns a null value) causes an exception which crashes the web server while returning null produces an exception which is handled in the debugger.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;As you can see in the code above, the offending line of code was commented out. But, it was a good lesson to learn about SiteMapProvider development. When calling the Add method on a SiteMapNode the provider’s abstract methods will get called; and they’re a bit touchy.&lt;/p&gt;&lt;br /&gt;&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:dae42135-f210-4a5e-9ff5-25d80e5b051e" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Exception" rel="tag"&gt;Exception&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SiteMapProvider" rel="tag"&gt;SiteMapProvider&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-5279072761719893314?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/5279072761719893314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/04/sitemapprovider-exception-crashes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/5279072761719893314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/5279072761719893314'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/04/sitemapprovider-exception-crashes.html' title='SiteMapProvider Exception Crashes the Website'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-248768039922594980.post-6906301592114818846</id><published>2009-04-20T21:55:00.001-07:00</published><updated>2009-04-22T13:43:03.287-07:00</updated><title type='text'>Assembly NullReferenceException &amp; .NET Reflector</title><content type='html'>&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I was receiving a &lt;a href="http://www.nunit.org/index.php"&gt;NullReferenceException&lt;/a&gt; when running a third party dll through &lt;a href="http://www.nunit.org/index.php"&gt;NUnit&lt;/a&gt;. Which made it difficult to debug, because I couldn’t step through/alter the third party dll’s source code.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Analysis&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Thankfully the stack trace showed the class, method, and line number of the error. I was able to look through the third party dll using &lt;a href="http://www.red-gate.com/products/reflector/"&gt;Reflector&lt;/a&gt;, and found this line:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div face="'Courier New',courier,monospace" size="8pt" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; direction: ltr; max-height: 200px; cursor: text;" id="codeSnippetWrapper"&gt;   &lt;blockquote style="margin-right: 0px;" dir="ltr"&gt;     &lt;p&gt;builder.AppendLine(Assembly.GetEntryAssembly().Location);&lt;/p&gt;  &lt;/blockquote&gt;  &lt;/div&gt;  &lt;p&gt;It seemed pretty straight forward that the GetEntryAssembly() method call was returning a null value. But, why?&lt;/p&gt;  &lt;p&gt;The explanation came from the remarks section (among other places on the page) of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getentryassembly.aspx"&gt;MSDN documentation&lt;/a&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The &lt;strong&gt;GetEntryAssembly&lt;/strong&gt; method can return null (Nothing in Visual Basic) when a managed assembly has been loaded from an unmanaged application. For example, if an unmanaged application creates an instance of a COM component written in C#, a call to the &lt;strong&gt;GetEntryAssembly&lt;/strong&gt; method from the C# component returns null, because the entry point for the process was unmanaged code rather than a managed assembly.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I had always thought that NUnit was managed code, but maybe there was an intermediate level of unmanaged code which was executing NUnit. This seemed probable because NUnit was being called from &lt;a href="http://nant.sourceforge.net/"&gt;NAnt&lt;/a&gt; which was being called from &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET"&gt;CruiseControl.Net&lt;/a&gt;. And, the error was not happening when I was ran NUnit through &lt;a href="http://www.jetbrains.com/resharper/"&gt;ReSharper&lt;/a&gt; within Visual Studio. &lt;/p&gt;  &lt;p&gt;I just needed a way to update the third party source code to remove/rewrite the offending line.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Reflector has a &lt;a href="http://www.denisbauer.com/NETTools/FileDisassembler.aspx"&gt;FileDisassembler addin&lt;/a&gt; which can take the decompiled output and write it to disk. It can even take an entire dll and create a Visual Studio project when exporting the code.&lt;/p&gt;  &lt;p&gt;The decompiled output for this assembly had a few compile errors, but started working after a few redundant “compile-fix-error” steps in Visual Studio.&lt;/p&gt;  &lt;p&gt;Once the solution was updated to use the decompiled code, I added in a static method which replaced all calls to Assembly.GetEntryAssembly() within the project:&lt;/p&gt;  &lt;div style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;" id="codeSnippetWrapper"&gt;   &lt;div    style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;     &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Reflection;&lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt; &lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; Some.Namespace&lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;{&lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;/// This class handles retrieving assemblies which have the potential of returning null values.&lt;/span&gt;&lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre face="'Courier New',courier,monospace" size="8pt" color="black" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; direction: ltr;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; AssemblyHandler&lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;    {&lt;/pre&gt;   &lt;pre face="'Courier New',courier,monospace" size="8pt" color="black" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; direction: ltr;"&gt; &lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre face="'Courier New',courier,monospace" size="8pt" color="black" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; direction: ltr;"&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;/// Retrieves the entry assembly when available. If it is not available then the calling&lt;/span&gt;&lt;/pre&gt;   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; direction: ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;"&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;/// assembly is returned.&lt;/span&gt;&lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre face="'Courier New',courier,monospace" size="8pt" color="black" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; direction: ltr;"&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;/// &amp;lt;returns&amp;gt;The highest level executing assembly which can be found within executing AppDomain.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; Assembly GetEntryAssembly() {&lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;            Assembly    asm    = Assembly.GetEntryAssembly();&lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;( asm == &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt; )    asm    = Assembly.GetCallingAssembly();&lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; asm;&lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;        }&lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt; &lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    }&lt;/pre&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;}&lt;/pre&gt; &lt;/div&gt; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;After a new compile, the NullReferenceException disappeared.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:dae42135-f210-4a5e-9ff5-25d80e5b051e" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET+Assembly" rel="tag"&gt;.NET Assembly&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Exception" rel="tag"&gt;Exception&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET+Reflector" rel="tag"&gt;.NET Reflector&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/248768039922594980-6906301592114818846?l=stevenmaglio.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://stevenmaglio.blogspot.com/feeds/6906301592114818846/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://stevenmaglio.blogspot.com/2009/04/assembly-nullreferenceexception-net.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/6906301592114818846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/248768039922594980/posts/default/6906301592114818846'/><link rel='alternate' type='text/html' href='http://stevenmaglio.blogspot.com/2009/04/assembly-nullreferenceexception-net.html' title='Assembly NullReferenceException &amp;amp; .NET Reflector'/><author><name>smaglio81</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DoBtBBqas2w/SeuA1VKXC6I/AAAAAAAAAAM/K9ivmQxe8Fk/s1600-R/my_head_cropped_bigger.png'/></author><thr:total>1</thr:total></entry></feed>
