Congratulations!

[Valid Atom 1.0] This is a valid Atom 1.0 feed.

Recommendations

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

Source: http://feeds2.feedburner.com/SquaredRoot/

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <feed xmlns="http://www.w3.org/2005/Atom">
  3.  
  4. <title>Troy Goode</title>
  5. <link href="http://www.squaredroot.com/atom.xml" rel="self"/>
  6. <link href="http://www.squaredroot.com/"/>
  7. <updated>2016-08-15T00:53:49+00:00</updated>
  8. <id>http://www.squaredroot.com</id>
  9. <author>
  10.   <name>Troy Goode</name>
  11.   <email>troygoode@gmail.com</email>
  12. </author>
  13.  
  14. <entry>
  15.   <title>npm install cors</title>
  16.   <link href="http://www.squaredroot.com/2014/05/09/npm-install-cors/"/>
  17.   <updated>2014-05-09T00:00:00+00:00</updated>
  18.   <id>http://www.squaredroot.com/2014/05/09/npm-install-cors</id>
  19.   <content type="html">&lt;p&gt;CORS is a popular node.js package I&amp;#39;ve written that provides an &lt;a href=&quot;http://expressjs.com/&quot;&gt;Express&lt;/a&gt; middleware you can use to enable &lt;a href=&quot;http://en.wikipedia.org/wiki/Cross-origin_resource_sharing&quot;&gt;CORS&lt;/a&gt; with various options. The code is open source (&lt;a href=&quot;http://www.opensource.org/licenses/mit-license.php&quot;&gt;MIT License&lt;/a&gt;) and &lt;a href=&quot;https://github.com/troygoode/node-cors&quot;&gt;available on GitHub&lt;/a&gt;.&lt;/p&gt;
  20.  
  21. &lt;h2&gt;Installation (via &lt;a href=&quot;https://npmjs.org/package/cors&quot;&gt;npm&lt;/a&gt;)&lt;/h2&gt;
  22. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;npm install cors
  23. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  24. &lt;h2&gt;Usage&lt;/h2&gt;
  25.  
  26. &lt;h3&gt;Simple Usage (Enable &lt;em&gt;All&lt;/em&gt; CORS Requests)&lt;/h3&gt;
  27. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;express&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  28.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;cors&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  29.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  30.  
  31. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
  32. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;router&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  33.  
  34. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;/products/:id&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  35.  &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;This is CORS-enabled for all origins!&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  36. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  37.  
  38. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
  39.  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;CORS-enabled web server listening on port 80&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  40. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  41. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  42. &lt;h3&gt;Enable CORS for a Single Route&lt;/h3&gt;
  43. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;express&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  44.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;cors&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  45.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  46.  
  47. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;/products/:id&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  48.  &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;This is CORS-enabled for all origins!&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  49. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  50.  
  51. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
  52.  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;CORS-enabled web server listening on port 80&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  53. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  54. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  55. &lt;h3&gt;Configuring CORS&lt;/h3&gt;
  56. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;express&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  57.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;cors&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  58.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  59.  
  60. &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;corsOptions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  61.  &lt;span class=&quot;na&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;http://example.com&#39;&lt;/span&gt;
  62. &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  63.  
  64. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;/products/:id&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;corsOptions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  65.  &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;This is CORS-enabled for only example.com.&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  66. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  67.  
  68. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
  69.  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;CORS-enabled web server listening on port 80&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  70. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  71. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  72. &lt;h3&gt;Configuring CORS w/ Dynamic Origin&lt;/h3&gt;
  73. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;express&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  74.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;cors&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  75.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  76.  
  77. &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;whitelist&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;http://example1.com&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;http://example2.com&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
  78. &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;corsOptions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  79.  &lt;span class=&quot;na&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  80.    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;originIsWhitelisted&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;whitelist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  81.    &lt;span class=&quot;nx&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;originIsWhitelisted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  82.  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  83. &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  84.  
  85. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;/products/:id&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;corsOptions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  86.  &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;This is CORS-enabled for a whitelisted domain.&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  87. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  88.  
  89. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
  90.  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;CORS-enabled web server listening on port 80&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  91. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  92. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  93. &lt;h3&gt;Enabling CORS Pre-Flight&lt;/h3&gt;
  94.  
  95. &lt;p&gt;Certain CORS requests are considered &amp;#39;complex&amp;#39; and require an initial
  96. &lt;code&gt;OPTIONS&lt;/code&gt; request (called the &amp;quot;pre-flight request&amp;quot;). An example of a
  97. &amp;#39;complex&amp;#39; CORS request is one that uses an HTTP verb other than
  98. GET/HEAD/POST (such as DELETE) or that uses custom headers. To enable
  99. pre-flighting, you must add a new OPTIONS handler for the route you want
  100. to support:&lt;/p&gt;
  101. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;express&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  102.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;cors&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  103.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  104.  
  105. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;/products/:id&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// enable pre-flight request for DELETE request&lt;/span&gt;
  106. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;del&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;/products/:id&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  107.  &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;This is CORS-enabled for all origins!&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  108. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  109.  
  110. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
  111.  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;CORS-enabled web server listening on port 80&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  112. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  113. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  114. &lt;p&gt;You can also enable pre-flight across-the-board like so:&lt;/p&gt;
  115. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;app.options(&#39;*&#39;, cors()); // include before other routes
  116. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  117. &lt;h3&gt;Configuring CORS Asynchronously&lt;/h3&gt;
  118. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;express&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  119.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;cors&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  120.  &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  121.  
  122. &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;whitelist&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;http://example1.com&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;http://example2.com&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
  123. &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;corsOptionsDelegate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  124.  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;corsOptions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  125.  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;whitelist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;Origin&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  126.    &lt;span class=&quot;nx&quot;&gt;corsOptions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// reflect (enable) the requested origin in the CORS response&lt;/span&gt;
  127.  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  128.    &lt;span class=&quot;nx&quot;&gt;corsOptions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// disable CORS for this request&lt;/span&gt;
  129.  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  130.  &lt;span class=&quot;nx&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;corsOptions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// callback expects two parameters: error and options&lt;/span&gt;
  131. &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  132.  
  133. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;/products/:id&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;corsOptionsDelegate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  134.  &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;This is CORS-enabled for a whitelisted domain.&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  135. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  136.  
  137. &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
  138.  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;CORS-enabled web server listening on port 80&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  139. &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  140. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  141. &lt;h2&gt;Configuration Options&lt;/h2&gt;
  142.  
  143. &lt;ul&gt;
  144. &lt;li&gt;&lt;code&gt;origin&lt;/code&gt;: Configures the &lt;strong&gt;Access-Control-Allow-Origin&lt;/strong&gt; CORS header. Expects a string (ex: &amp;quot;http://example.com&amp;quot;). Set to &lt;code&gt;true&lt;/code&gt; to reflect the &lt;a href=&quot;http://tools.ietf.org/html/draft-abarth-origin-09&quot;&gt;request origin&lt;/a&gt;, as defined by &lt;code&gt;req.header(&amp;#39;Origin&amp;#39;)&lt;/code&gt;. Set to &lt;code&gt;false&lt;/code&gt; to disable CORS. Can also be set to a function, which takes the request origin as the first parameter and a callback (which expects the signature &lt;code&gt;err [object], allow [bool]&lt;/code&gt;) as the second.&lt;/li&gt;
  145. &lt;li&gt;&lt;code&gt;methods&lt;/code&gt;: Configures the &lt;strong&gt;Access-Control-Allow-Methods&lt;/strong&gt; CORS header. Expects a comma-delimited string (ex: &amp;#39;GET,PUT,POST&amp;#39;) or an array (ex: &lt;code&gt;[&amp;#39;GET&amp;#39;, &amp;#39;PUT&amp;#39;, &amp;#39;POST&amp;#39;]&lt;/code&gt;).&lt;/li&gt;
  146. &lt;li&gt;&lt;code&gt;allowedHeaders&lt;/code&gt;: Configures the &lt;strong&gt;Access-Control-Allow-Headers&lt;/strong&gt; CORS header. Expects a comma-delimited string (ex: &amp;#39;Content-Type,Authorization&amp;#39;) or an array (ex: &lt;code&gt;[&amp;#39;Content-Type&amp;#39;, &amp;#39;Authorization]&lt;/code&gt;). If not specified, defaults to reflecting the headers specified in the request&amp;#39;s &lt;strong&gt;Access-Control-Request-Headers&lt;/strong&gt; header.&lt;/li&gt;
  147. &lt;li&gt;&lt;code&gt;exposedHeaders&lt;/code&gt;: Configures the &lt;strong&gt;Access-Control-Expose-Headers&lt;/strong&gt; CORS header. Expects a comma-delimited string (ex: &amp;#39;Content-Range,X-Content-Range&amp;#39;) or an array (ex: &lt;code&gt;[&amp;#39;Content-Range&amp;#39;, &amp;#39;X-Content-Range]&lt;/code&gt;). If not specified, no custom headers are exposed.&lt;/li&gt;
  148. &lt;li&gt;&lt;code&gt;credentials&lt;/code&gt;: Configures the &lt;strong&gt;Access-Control-Allow-Credentials&lt;/strong&gt; CORS header. Set to &lt;code&gt;true&lt;/code&gt; to pass the header, otherwise it is omitted.&lt;/li&gt;
  149. &lt;li&gt;&lt;code&gt;maxAge&lt;/code&gt;: Configures the &lt;strong&gt;Access-Control-Allow-Max-Age&lt;/strong&gt; CORS header. Set to an integer to pass the header, otherwise it is omitted.&lt;/li&gt;
  150. &lt;/ul&gt;
  151.  
  152. &lt;p&gt;For details on the effect of each CORS header, &lt;a href=&quot;http://www.html5rocks.com/en/tutorials/cors/&quot;&gt;read this article on HTML5 Rocks&lt;/a&gt;.&lt;/p&gt;
  153.  
  154. &lt;h2&gt;Demo&lt;/h2&gt;
  155.  
  156. &lt;p&gt;A demo that illustrates CORS working (and not working) using jQuery is available here: &lt;a href=&quot;http://node-cors-client.herokuapp.com/&quot;&gt;http://node-cors-client.herokuapp.com/&lt;/a&gt;&lt;/p&gt;
  157.  
  158. &lt;p&gt;Code for that demo can be found here:&lt;/p&gt;
  159.  
  160. &lt;ul&gt;
  161. &lt;li&gt;Client: &lt;a href=&quot;https://github.com/TroyGoode/node-cors-client&quot;&gt;https://github.com/TroyGoode/node-cors-client&lt;/a&gt;&lt;/li&gt;
  162. &lt;li&gt;Server: &lt;a href=&quot;https://github.com/TroyGoode/node-cors-server&quot;&gt;https://github.com/TroyGoode/node-cors-server&lt;/a&gt;&lt;/li&gt;
  163. &lt;/ul&gt;
  164. </content>
  165. </entry>
  166. <entry>
  167.   <title>npm install require-directory</title>
  168.   <link href="http://www.squaredroot.com/2012/12/16/npm-install-require-directory/"/>
  169.   <updated>2012-12-16T00:00:00+00:00</updated>
  170.   <id>http://www.squaredroot.com/2012/12/16/npm-install-require-directory</id>
  171.   <content type="html">&lt;p&gt;A common pattern I have found when building node.js applications
  172. revolves around how you refactor a large file into a directory of
  173. smaller files. For example, in an &lt;a href=&quot;http://expressjs.com&quot;&gt;Express&lt;/a&gt; app
  174. you might start out defining routes in your &lt;em&gt;app.js&lt;/em&gt; file, but
  175. eventually migrate those routes into a &lt;em&gt;routes.js&lt;/em&gt; file that is then
  176. required into &lt;em&gt;app.js&lt;/em&gt;. What happens when &lt;em&gt;routes.js&lt;/em&gt; grows too large
  177. though? You chunk it up. You often end up with a &lt;em&gt;routes/&lt;/em&gt; directory,
  178. giving you a project structure that looks something like this:&lt;/p&gt;
  179.  
  180. &lt;ul&gt;
  181. &lt;li&gt;app.js&lt;/li&gt;
  182. &lt;li&gt;routes/
  183.  
  184. &lt;ul&gt;
  185. &lt;li&gt;auth.js&lt;/li&gt;
  186. &lt;li&gt;home.js&lt;/li&gt;
  187. &lt;li&gt;products.js&lt;/li&gt;
  188. &lt;/ul&gt;&lt;/li&gt;
  189. &lt;/ul&gt;
  190.  
  191. &lt;p&gt;I also find it common to throw an &lt;em&gt;index.js&lt;/em&gt; file into that &lt;em&gt;routes/&lt;/em&gt;
  192. directory, which might look like:&lt;/p&gt;
  193.  
  194. &lt;script src=&quot;https://gist.github.com/4310301.js?file=index.js&quot;&gt; &lt;/script&gt;
  195.  
  196. &lt;p&gt;Eventually you might find that &lt;em&gt;routes/auth.js&lt;/em&gt; has grown too large for
  197. one file as well, and you may refactor your files to look more like so:&lt;/p&gt;
  198.  
  199. &lt;ul&gt;
  200. &lt;li&gt;app.js&lt;/li&gt;
  201. &lt;li&gt;routes/
  202.  
  203. &lt;ul&gt;
  204. &lt;li&gt;auth/&lt;/li&gt;
  205. &lt;li&gt;login.js&lt;/li&gt;
  206. &lt;li&gt;logout.js&lt;/li&gt;
  207. &lt;li&gt;register.js&lt;/li&gt;
  208. &lt;li&gt;home.js&lt;/li&gt;
  209. &lt;li&gt;products.js&lt;/li&gt;
  210. &lt;/ul&gt;&lt;/li&gt;
  211. &lt;/ul&gt;
  212.  
  213. &lt;p&gt;This changes your &lt;em&gt;routes/index.js&lt;/em&gt; file into:&lt;/p&gt;
  214.  
  215. &lt;script src=&quot;https://gist.github.com/4310301.js?file=index2.js&quot;&gt; &lt;/script&gt;
  216.  
  217. &lt;p&gt;... and so on and so forth. As node.js applications grow larger I see
  218. this pattern repeated over and over, often within the same application.
  219. To that end, I created &lt;strong&gt;require-directory&lt;/strong&gt; - an
  220. &lt;a href=&quot;http://npmjs.org&quot;&gt;npm&lt;/a&gt; package that simplifies that &lt;em&gt;index.js&lt;/em&gt; file
  221. down into:&lt;/p&gt;
  222.  
  223. &lt;script src=&quot;https://gist.github.com/4310301.js?file=index3.js&quot;&gt; &lt;/script&gt;
  224.  
  225. &lt;p&gt;For more information, &lt;a href=&quot;https://github.com/troygoode/node-require-directory&quot;&gt;check out the package&amp;#39;s GitHub page.&lt;/a&gt;&lt;/p&gt;
  226. </content>
  227. </entry>
  228. <entry>
  229.   <title>PagedList can haz HtmlHelperz?</title>
  230.   <link href="http://www.squaredroot.com/2011/06/28/pagedlist-can-haz-htmlhelperz/"/>
  231.   <updated>2011-06-28T00:00:00+00:00</updated>
  232.   <id>http://www.squaredroot.com/2011/06/28/pagedlist-can-haz-htmlhelperz</id>
  233.   <content type="html">&lt;p&gt;Wow, has it already been almost two years since my &lt;a href=&quot;/2009/08/15/spearmen-javelin-throwers-and-the-state-pattern-oh-my/&quot;&gt;last post&lt;/a&gt;?&lt;/p&gt;
  234.  
  235. &lt;p&gt;Back in March I made some modifications to the &lt;a href=&quot;http://github.com/troygoode/pagedlist&quot;&gt;PagedList library&lt;/a&gt; I&amp;#39;ve been working on the last couple of years to (finally) add an HTML Helper that can generate the HTML paging code you frequently will use alongside the PagedList library. Over the last few days I have tweaked everything a bit more and am now quite happy with where the library sits.&lt;/p&gt;
  236.  
  237. &lt;h2&gt;Installation&lt;/h2&gt;
  238.  
  239. &lt;p&gt;You can install via Nuget:&lt;/p&gt;
  240. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Install-Package PagedList
  241. Install-Package PagedList.Mvc
  242. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  243. &lt;p&gt;Alternatively, &lt;a href=&quot;https://github.com/TroyGoode/PagedList&quot;&gt;download the source&lt;/a&gt; straight from GitHub.&lt;/p&gt;
  244.  
  245. &lt;h2&gt;What does PagedList do again?&lt;/h2&gt;
  246.  
  247. &lt;p&gt;The first package contains the core PagedList library, which allows you to do this:&lt;/p&gt;
  248.  
  249. &lt;script src=&quot;https://gist.github.com/1053069.js&quot;&gt; &lt;/script&gt;
  250.  
  251. &lt;h2&gt;Okay, so what is PagedList.Mvc then?&lt;/h2&gt;
  252.  
  253. &lt;p&gt;The second package contains the new HTML Helper which lets you render pagers that look like this:&lt;/p&gt;
  254.  
  255. &lt;p&gt;&lt;img src=&quot;/custom/files/old/DefaultPagingControlStyles.png&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  256.  
  257. &lt;p&gt;&lt;em&gt;Note: All elements rendered by the HTML Helper have CSS classes applied to allow you to easily modify styling.&lt;/em&gt;&lt;/p&gt;
  258.  
  259. &lt;p&gt;You call the HTML Helper like so:&lt;/p&gt;
  260.  
  261. &lt;script src=&quot;https://gist.github.com/1053136.js&quot;&gt; &lt;/script&gt;
  262.  
  263. &lt;h2&gt;Customizing the Rendering Options&lt;/h2&gt;
  264.  
  265. &lt;p&gt;There are several out-of-the-box render configurations as you can see above, and you can also pass ad-hoc render configurations to the render method (also shown above). Sometimes, though, you want to create a render configuration that will be used repeatedly throughout your application. This is easy to do as well:&lt;/p&gt;
  266.  
  267. &lt;script src=&quot;https://gist.github.com/1053159.js&quot;&gt; &lt;/script&gt;
  268.  
  269. &lt;p&gt;For more information on the available rendering option settings, check &lt;a href=&quot;https://github.com/TroyGoode/PagedList/blob/master/src/PagedList.Mvc/PagedListRenderOptions.cs&quot;&gt;PagedListRenderingOptions.cs&lt;/a&gt; on GitHub.&lt;/p&gt;
  270. </content>
  271. </entry>
  272. <entry>
  273.   <title>Spearmen, Javelin Throwers, and the State Pattern. Oh My!</title>
  274.   <link href="http://www.squaredroot.com/2009/08/15/spearmen-javelin-throwers-and-the-state-pattern-oh-my/"/>
  275.   <updated>2009-08-15T00:00:00+00:00</updated>
  276.   <id>http://www.squaredroot.com/2009/08/15/spearmen-javelin-throwers-and-the-state-pattern-oh-my</id>
  277.   <content type="html">&lt;p&gt;Last week one of Ayende/Oren&amp;#39;s posts caught my eye: &lt;a href=&quot;http://ayende.com/Blog/archive/2009/08/05/let-the-fighting-commence.aspx&quot;&gt;Let the fighting commence!&lt;/a&gt; In it he discussed &lt;a href=&quot;http://www.thecodespring.com/2009/08/interface-overload.html&quot;&gt;a blog post seen on Jamie Farser&amp;#39;s blog&lt;/a&gt;, where Jamie discusses some design difficulties he has run into while designing a turn-based game similar to Axis &amp;amp; Allies named &lt;a href=&quot;http://code.google.com/p/everland/&quot;&gt;Everland&lt;/a&gt;. Since then I&amp;#39;ve been following Jamie&amp;#39;s progress (&lt;a href=&quot;http://www.thecodespring.com/2009/08/state-pattern.html&quot;&gt;first try&lt;/a&gt;, &lt;a href=&quot;http://www.thecodespring.com/2009/08/state-pattern-part-15.html&quot;&gt;further exploration&lt;/a&gt;, &lt;a href=&quot;http://www.thecodespring.com/2009/08/state-pattern-part-2-of.html&quot;&gt;second try&lt;/a&gt;, &lt;a href=&quot;http://www.thecodespring.com/2009/08/state-pattern-part-3.html&quot;&gt;third try&lt;/a&gt;, &lt;a href=&quot;http://www.thecodespring.com/2009/08/state-pattern-transitions.html&quot;&gt;even further exploration&lt;/a&gt;) as he tries to take some of Ayende&amp;#39;s advice and implement the state pattern. Like Jamie, I am fairly new to the state pattern - sure I&amp;#39;ve read about it plenty (starting in &lt;a href=&quot;http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124&quot;&gt;Head First Design Patterns&lt;/a&gt; - a must have!), but I honestly have just never implemented it &amp;quot;for reals.&amp;quot; In my back &amp;amp; forth with Jamie I realized that it was time to put up or shut up - if I&amp;#39;m going to offer criticism I should also offer up an alternative solution.&lt;/p&gt;
  278.  
  279. &lt;h2&gt;The Problem&lt;/h2&gt;
  280.  
  281. &lt;p&gt;Let&amp;#39;s say we have a game where the board is made up of six-side polygons (&amp;quot;hexes&amp;quot;, if you will) and each hex can contain a unit like a spearman or a javelin thrower. Each unit on the board belongs to a player who can take turns moving his units, telling his units to attack other player&amp;#39;s units, etc. Some units have different capabilities than other units - a spearman must be within 1 hex of another unit to attack that unit, whereas a javelin thrower can be 2 units away. How do we design the application in such a way that:&lt;/p&gt;
  282.  
  283. &lt;ul&gt;
  284. &lt;li&gt;The game engine doesn&amp;#39;t need to know specifics about each unit (such as range of attack).&lt;/li&gt;
  285. &lt;li&gt;A unit&amp;#39;s capabilities may change during the course of gameplay (such as a spearman being upgraded to a javelin thrower).&lt;/li&gt;
  286. &lt;/ul&gt;
  287.  
  288. &lt;h2&gt;My Solution&lt;/h2&gt;
  289.  
  290. &lt;p&gt;Before we look at the code, lets run through what is going to happen in-game.&lt;/p&gt;
  291.  
  292. &lt;ol&gt;
  293. &lt;li&gt;The user selects one of their units, then selects an opposing unit somewhere else on the gameboard, then clicks an &amp;quot;Attack&amp;quot; button.&lt;/li&gt;
  294. &lt;li&gt;The game engine creates a context (deriving from &lt;strong&gt;ITurnContext&lt;/strong&gt;) that describes what the user has asked to do. In our case, an &lt;strong&gt;AttackContext&lt;/strong&gt; is created containing references to the attacking unit and the defending unit.&lt;/li&gt;
  295. &lt;li&gt;That context is then passed into the &lt;em&gt;ExecuteTurn&lt;/em&gt; method of the attacking &lt;strong&gt;Unit&lt;/strong&gt;, which then passes it along into the &lt;em&gt;Handle&lt;/em&gt; method of its &lt;em&gt;CurrentState&lt;/em&gt; property (which is an object deriving from &lt;strong&gt;UnitState&lt;/strong&gt;). Our attacker&amp;#39;s &lt;em&gt;CurrentState&lt;/em&gt; property is currently &lt;strong&gt;Spearman&lt;/strong&gt;, but could just as easily be &lt;strong&gt;JavelinThrower&lt;/strong&gt;. Changing a unit from melee to ranged is as simple as changing the state of that unit.&lt;/li&gt;
  296. &lt;li&gt;Our &lt;strong&gt;Spearman&lt;/strong&gt; state derives from &lt;strong&gt;UnitState&lt;/strong&gt;, and the &lt;strong&gt;UnitState&lt;/strong&gt; base class&amp;#39; &lt;em&gt;Handle&lt;/em&gt; method uses &lt;a href=&quot;http://en.wikipedia.org/wiki/Double_dispatch&quot;&gt;double dispatch&lt;/a&gt; to forward the &lt;em&gt;Handle&lt;/em&gt; request on to the appropriate method of our subclass. In our case that would be the &lt;em&gt;Handle&lt;/em&gt; (&lt;em&gt;AttackContext&lt;/em&gt;) method of the &lt;em&gt;Spearman&lt;/em&gt; class.&lt;/li&gt;
  297. &lt;li&gt;Our &lt;strong&gt;Spearman&lt;/strong&gt; class&amp;#39; &lt;em&gt;Handle&lt;/em&gt; method then checks to see if the unit is within range to attack the defending unit - if it is, an &lt;strong&gt;AttackCommand&lt;/strong&gt; is returned denoting who the attacker and the defender are; if it isn&amp;#39;t, a &lt;strong&gt;MovementCommand&lt;/strong&gt; is returned denoting which hex to move to.&lt;/li&gt;
  298. &lt;li&gt;The &lt;strong&gt;Unit&lt;/strong&gt; class then calls &lt;em&gt;Execute&lt;/em&gt; on the returned command, causing the movement or attack operation to be, well, executed.&lt;/li&gt;
  299. &lt;/ol&gt;
  300.  
  301. &lt;p&gt;Let&amp;#39;s go through each of the above steps and take a look at the code involved one by one. Skipping the first step (the UI), we&amp;#39;ll move on to where the game engine is creating an &lt;strong&gt;AttackContext&lt;/strong&gt; and passing it into the attacking &lt;strong&gt;Unit&lt;/strong&gt;:&lt;/p&gt;
  302.  
  303. &lt;script src=&quot;https://gist.github.com/3998655.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  304.  
  305. &lt;p&gt;Okay, easy enough. Moving on we can see the &lt;strong&gt;Unit&lt;/strong&gt; class&amp;#39; &lt;em&gt;ExecuteTurn&lt;/em&gt; method pass the context to its &lt;em&gt;CurrentState&lt;/em&gt; property&amp;#39;s &lt;em&gt;Handle&lt;/em&gt; method:&lt;/p&gt;
  306.  
  307. &lt;script src=&quot;https://gist.github.com/3998655.js?file=Example-2.cs&quot;&gt; &lt;/script&gt;
  308.  
  309. &lt;p&gt;Our attacking unit&amp;#39;s &lt;em&gt;CurrentState&lt;/em&gt; property is currently set to an instance of &lt;strong&gt;Spearman&lt;/strong&gt;, but before we take a look at that class we&amp;#39;ll take a look at its base class (&lt;strong&gt;UnitState&lt;/strong&gt; - which is doing double dispatch to the &lt;strong&gt;Spearman&lt;/strong&gt;&amp;#39;s &lt;em&gt;Handle&lt;/em&gt; method):&lt;/p&gt;
  310.  
  311. &lt;script src=&quot;https://gist.github.com/3998655.js?file=Example-3.cs&quot;&gt; &lt;/script&gt;
  312.  
  313. &lt;p&gt;The Spearman class&amp;#39; Handle method is then invoked:&lt;/p&gt;
  314.  
  315. &lt;script src=&quot;https://gist.github.com/3998655.js?file=Example-4.cs&quot;&gt; &lt;/script&gt;
  316.  
  317. &lt;p&gt;Notice that the only concern &lt;strong&gt;Spearman&lt;/strong&gt; currently has when handling an attack context is ensuring that it gets within range and then attacks the target. We&amp;#39;ll see an example of a &lt;strong&gt;JavelinThrower&lt;/strong&gt; later. Finally we&amp;#39;ll peek at what the &lt;strong&gt;MovementCommand&lt;/strong&gt; and &lt;strong&gt;AttackCommand&lt;/strong&gt; actually do:&lt;/p&gt;
  318.  
  319. &lt;script src=&quot;https://gist.github.com/3998655.js?file=Example-5.cs&quot;&gt; &lt;/script&gt;
  320.  
  321. &lt;p&gt;Before we move on, here is the promised &lt;strong&gt;JavelinThrower&lt;/strong&gt; class:&lt;/p&gt;
  322.  
  323. &lt;script src=&quot;https://gist.github.com/3998655.js?file=Example-6.cs&quot;&gt; &lt;/script&gt;
  324.  
  325. &lt;p&gt;Obviously &lt;strong&gt;JavelinThrower&lt;/strong&gt; &amp;amp; &lt;strong&gt;Spearman&lt;/strong&gt; currently only differ in the range at which they can attack (&amp;lt;=2 and &amp;lt;= 1, respectively), so the code in their &lt;em&gt;Handle&lt;/em&gt; methods could be abstracted out using the &lt;a href=&quot;http://en.wikipedia.org/wiki/Strategy_pattern&quot;&gt;strategy pattern&lt;/a&gt;.&lt;/p&gt;
  326.  
  327. &lt;h2&gt;Prove It!&lt;/h2&gt;
  328.  
  329. &lt;p&gt;So now that we&amp;#39;ve had a chance to see the code involved the question comes down to: does it actually work? Here are our unit tests:&lt;/p&gt;
  330.  
  331. &lt;script src=&quot;https://gist.github.com/3998655.js?file=Example-7.cs&quot;&gt; &lt;/script&gt;
  332.  
  333. &lt;p&gt;And the results...&lt;/p&gt;
  334.  
  335. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Spearman-JavelinThrower-Tests-Passed.PNG&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  336.  
  337. &lt;p&gt;Yay!&lt;/p&gt;
  338.  
  339. &lt;p&gt;So that is the road I went down, but what I really want to know is how would *you *solve this problem? If you&amp;#39;d like to take a deeper look at my code, download it and give it a try yourself:&lt;/p&gt;
  340.  
  341. &lt;p&gt;&lt;a href=&quot;/custom/files/old/EverlandStatePattern.zip&quot;&gt;EverlandStatePattern.zip&lt;/a&gt;&lt;/p&gt;
  342. </content>
  343. </entry>
  344. <entry>
  345.   <title>MVC Membership Starter Kit Released</title>
  346.   <link href="http://www.squaredroot.com/2009/08/07/mvcmembership-release-1-0/"/>
  347.   <updated>2009-08-07T00:00:00+00:00</updated>
  348.   <id>http://www.squaredroot.com/2009/08/07/mvcmembership-release-1-0</id>
  349.   <content type="html">&lt;p class=&quot;warning&quot;&gt;These instructions are out of date, and a newer version of the Membership Starter Kit is now available with support for ASP.NET MVC 4 and installation via NuGet. For more information, &lt;a href=&quot;https://github.com/troygoode/membershipstarterkit&quot;&gt;look the project up on GitHub&lt;/a&gt;.&lt;/p&gt;
  350.  
  351. &lt;p&gt;Almost six months after the &lt;a href=&quot;http://haacked.com/archive/2009/03/18/aspnet-mvc-rtw.aspx&quot;&gt;official release of Asp.Net MVC 1.0&lt;/a&gt; and nearly a year after &lt;a href=&quot;/2008/09/06/mvc-membership-preview-5/&quot;&gt;the last release of the starter kit&lt;/a&gt;, I&amp;#39;ve finally rewritten and released the Asp.Net MVC Membership Starter Kit. If you&amp;#39;re already familiar with what it is and want to grab it, you can find the release on the &lt;a href=&quot;https://github.com/troygoode/membershipstarterkit&quot;&gt;GitHub project site&lt;/a&gt;.&lt;/p&gt;
  352.  
  353. &lt;h2&gt;What is the Asp.Net MVC Membership Starter Kit?&lt;/h2&gt;
  354.  
  355. &lt;p&gt;The starter kit currently consists of two things:&lt;/p&gt;
  356.  
  357. &lt;ul&gt;
  358. &lt;li&gt;A sample website containing the controllers, models, and views needed to administer users &amp;amp; roles.&lt;/li&gt;
  359. &lt;li&gt;A library that provides testable interfaces for administering users &amp;amp; roles and concrete implementations of those interfaces that wrap the built-in Asp.Net Membership &amp;amp; Roles providers.&lt;/li&gt;
  360. &lt;/ul&gt;
  361.  
  362. &lt;h2&gt;How do I use it?&lt;/h2&gt;
  363.  
  364. &lt;p&gt;In Asp.Net MVC 1 there isn&amp;#39;t a great story for packaging &amp;amp; sharing controllers, views, and other resources so we&amp;#39;ll need to follow a few manual steps:&lt;/p&gt;
  365.  
  366. &lt;ul&gt;
  367. &lt;li&gt;After getting the source code build it using your preferred IDE or using the included &lt;strong&gt;Build.Debug.bat&lt;/strong&gt; or &lt;strong&gt;Build.Release.bat&lt;/strong&gt; batch files.&lt;/li&gt;
  368. &lt;li&gt;Grab the &lt;strong&gt;MvcMembership.dll&lt;/strong&gt; assembly and place it wherever you&amp;#39;re including external libraries in your project. Add a reference to the assembly to your Asp.Net MVC application.&lt;/li&gt;
  369. &lt;li&gt;Copy the &lt;strong&gt;UserAdministrationController.cs&lt;/strong&gt; file from the &lt;em&gt;SampleWebsite&lt;/em&gt;&amp;#39;s &lt;em&gt;Controllers&lt;/em&gt; directory to your app&amp;#39;s &lt;em&gt;Controllers&lt;/em&gt; directory.&lt;/li&gt;
  370. &lt;li&gt;Copy the &lt;strong&gt;ISmtpClient.cs&lt;/strong&gt; file, &lt;strong&gt;SmtpClientProxy.cs&lt;/strong&gt; file, and &lt;strong&gt;UserAdministration&lt;/strong&gt; folder from the &lt;em&gt;SampleWebsite&lt;/em&gt;&amp;#39;s &lt;em&gt;Models *folder to your app&amp;#39;s *Models&lt;/em&gt; folder.&lt;/li&gt;
  371. &lt;li&gt;Copy the &lt;strong&gt;UserAdministration&lt;/strong&gt; folder from the &lt;em&gt;SampleWebsite&lt;/em&gt;&amp;#39;s &lt;em&gt;Views&lt;/em&gt; folder to your app&amp;#39;s &lt;em&gt;Views&lt;/em&gt; folder.&lt;/li&gt;
  372. &lt;li&gt;Make sure you&amp;#39;ve configured your &lt;strong&gt;web.config&lt;/strong&gt; properly for Membership and Roles. If you aren&amp;#39;t sure of how to do this, take a look at the first two articles in &lt;a href=&quot;http://www.4guysfromrolla.com/articles/120705-1.aspx&quot;&gt;this series by Scott Mitchell at 4GuysFromRolla&lt;/a&gt;.&lt;/li&gt;
  373. &lt;li&gt;Finally, add the following code to your &lt;strong&gt;global.asax&lt;/strong&gt; to keep the membership system updated with each user&amp;#39;s last activity date:&lt;/li&gt;
  374. &lt;/ul&gt;
  375.  
  376. &lt;script src=&quot;https://gist.github.com/3998701.js&quot;&gt; &lt;/script&gt;
  377.  
  378. &lt;h2&gt;What is new since the last release?&lt;/h2&gt;
  379.  
  380. &lt;p&gt;Well, the last release was for &lt;a href=&quot;http://mvcmembership.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=16809&quot;&gt;Preview 5&lt;/a&gt;, so at the very least the project has been updated for Beta and finally Release. Moreover, the project has been completely rewritten from scratch - a major undertaking that was the primary cause of the long delay between releases. Why the rewrite? Two reasons:&lt;/p&gt;
  381.  
  382. &lt;ul&gt;
  383. &lt;li&gt;The &lt;a href=&quot;http://mvcmembership.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=12215&quot;&gt;first release of the Starter Kit&lt;/a&gt; was for Preview 2 of the MVC framework. A lot changed between Preview 2 and Release - A LOT. A lot of the features of the first starter kit were rolled into the OTOB experience (such as login and registration), so I shifted the scope of the project more squarely into the realm of user &amp;amp; role administration. Unfortunately all of these major changes took a toll on the source - I was no longer happy working in the source as it was written for many reasons and thus wanted a rewrite. One of those reasons was...&lt;/li&gt;
  384. &lt;li&gt;Previous releases had no (as in zero, less than one, nada) unit tests. This became increasingly unacceptable to me and trying to add unit tests after-the-fact was a nightmare. Instead I rewrote the project using TDD.&lt;/li&gt;
  385. &lt;/ul&gt;
  386.  
  387. &lt;p&gt;Alright, so that was basically the long-winded spiel to prepare you for the bad news: the project regressed from a functionality perspective. During the course of the rewrite things some things didn&amp;#39;t make it in - chief among them is the OpenID integration. I encourage everyone to take a look at the Maarten Balliauw (an MvcMembership contributor) blog post on &lt;a href=&quot;http://blog.maartenballiauw.be/post/2009/07/27/Authenticating-users-with-RPXNow-%28in-ASPNET-MVC%29.aspx&quot;&gt;authenticating via RPX in MVC&lt;/a&gt;.&lt;/p&gt;
  388.  
  389. &lt;h2&gt;What comes next?&lt;/h2&gt;
  390.  
  391. &lt;p&gt;The primary motivator for me getting off my but after nearly a year and finishing up this release is my desire to convert it to an &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx&quot;&gt;&amp;quot;area&amp;quot; for use in MVC 2&lt;/a&gt;. Packaging reusable components like this has been a sore spot for the current MVC framework and I&amp;#39;m glad to see the blue badges are going to provide a common solution. Along with that I&amp;#39;ll likely try to add RPX authentication ala Maarten&amp;#39;s post.&lt;/p&gt;
  392. </content>
  393. </entry>
  394. <entry>
  395.   <title>Return of the PagedList</title>
  396.   <link href="http://www.squaredroot.com/2009/06/15/return-of-the-pagedlist/"/>
  397.   <updated>2009-06-15T00:00:00+00:00</updated>
  398.   <id>http://www.squaredroot.com/2009/06/15/return-of-the-pagedlist</id>
  399.   <content type="html">&lt;p class=&quot;warning&quot;&gt;I recommend grabbing the latest code from NuGet or directly from &lt;a href=&quot;https://github.com/troygoode/pagedlist&quot;&gt;the project&#39;s site on GitHub&lt;/a&gt;. The CodePlex project is no longer maintained.&lt;/p&gt;
  400.  
  401. &lt;p&gt;It has been nearly a year since I &lt;a href=&quot;/2008/07/08/PagedList-Strikes-Back/&quot;&gt;posted&lt;/a&gt; an updated version of the PagedList&amp;lt;T&amp;gt; functionality originally &lt;a href=&quot;http://blog.wekeroad.com/blog/aspnet-mvc-pagedlistt&quot;&gt;created by Scott Guthrie and posted by Rob Conery&lt;/a&gt;. Since then I have used the class in a number of projects and find it indispensable.&lt;/p&gt;
  402.  
  403. &lt;p&gt;A few days ago, Craig Stuntz reported an interesting observation: when the first page is returned, the class performs a Skip(0). Suprisingly, &lt;a href=&quot;http://blogs.teamb.com/craigstuntz/2009/06/10/38313/&quot;&gt;this is not free&lt;/a&gt;. With that in mind, I set out to correct that issue as well as incorporate a few changes I&amp;#39;ve made over the past year. The result is nearly identical to the last posted version, just a bit more readable. Additionally...&lt;/p&gt;
  404.  
  405. &lt;ul&gt;
  406. &lt;li&gt;The source is now available on CodePlex: &lt;a href=&quot;http://pagedlist.codeplex.com&quot;&gt;http://pagedlist.codeplex.com&lt;/a&gt;. This should make finding and downloading the code easier than finding the correct blog entry on some dude&amp;#39;s blog.&lt;/li&gt;
  407. &lt;li&gt;I have posted a release-compiled, XML commented, signed assembly on CodePlex. I got tired of having to copy the source into multiple projects and finding a place to put it in that project&amp;#39;s taxonomy.&lt;/li&gt;
  408. &lt;li&gt;Further incremental changes can be found in the Change Log on the CodePlex project site.&lt;/li&gt;
  409. &lt;/ul&gt;
  410. </content>
  411. </entry>
  412. <entry>
  413.   <title>Creating an MVC Project in Visual Studio 2010</title>
  414.   <link href="http://www.squaredroot.com/2009/06/09/creating-an-mvc-project-in-visual-studio-2010/"/>
  415.   <updated>2009-06-09T00:00:00+00:00</updated>
  416.   <id>http://www.squaredroot.com/2009/06/09/creating-an-mvc-project-in-visual-studio-2010</id>
  417.   <content type="html">&lt;p class=&quot;warning&quot;&gt;These instructions are not necessary with the RTM version of Visual Studio 2010 or later releases of Visual Studio.&lt;/p&gt;
  418.  
  419. &lt;p&gt;Earlier today &lt;a href=&quot;http://www.haacked.com/archive/2009/06/09/aspnetmvc-vs10beta1-roadmap.aspx&quot;&gt;Phil Haack announced&lt;/a&gt; that the Asp.Net MVC installer for Visual Studio 2010 Beta 1 is &lt;a href=&quot;http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28527&quot;&gt;now available on CodePlex&lt;/a&gt; along with the bonus of some basic snippets for use with MVC projects. This is exactly what I have been waiting for before installing Visual Studio 2010, so I decided to give it a shot and report back on my experience. I&amp;#39;m happy to say that the basic experience went flawlessly for me, though it appears &lt;a href=&quot;http://weblogs.asp.net/jacqueseloff/archive/2009/06/09/troubleshooting-the-mvc-installer-for-visual-studio-2010-beta-1.aspx&quot;&gt;that may not hold true for everyone&lt;/a&gt;.&lt;/p&gt;
  420.  
  421. &lt;p&gt;The first (and by far the longest) step in getting everything up and running is to download and install the Visual Studio 2010 beta. There are multiple flavors available, but I settled for the plain old Professional edition. You can also choose between the &lt;a href=&quot;http://www.microsoft.com/downloadS/details.aspx?familyid=3296BB4F-D8BA-4CFD-AA95-A424C5913F6B&amp;amp;displaylang=en&quot;&gt;full install 2 ISO download (1.1 GB)&lt;/a&gt; or a &lt;a href=&quot;http://www.microsoft.com/downloadS/details.aspx?familyid=75CBCBCD-B0E8-40EA-ADAE-85714E8984E3&amp;amp;displaylang=en&quot;&gt;lightweight (5 MB) &amp;quot;web install&amp;quot; package&lt;/a&gt;. I chose to try out the smaller package and it worked fine for me, though MSDN subscribers with slower connections may prefer to use the Microsoft download tool and download the bigger install so that they can pause and restart the download as needed. Either way, once you&amp;#39;ve downloaded everything grab a drink and kick off the install. On my relatively fast machine running Windows 7 it took close to half an hour to install and two (!) required restarts.&lt;/p&gt;
  422.  
  423. &lt;p&gt;Once Visual Studio has finished installing, download and install the &lt;a href=&quot;http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28527&quot;&gt;ASP.NET MVC 1.1 Installer for Visual Studio 2010 from CodePlex&lt;/a&gt;. While you&amp;#39;re there, go ahead and download and unzip ASP.NET MVC Snippets for VS2010 Beta 1. While Asp.Net MVC 1.1 is being installed, go ahead and install the snippets as well: unzip &amp;quot;ASP.NET MVC Snippets.zip&amp;quot; into &amp;quot;C:\Users&amp;amp;lt;username&amp;gt;\Documents\Visual Studio 10\Code Snippets\Visual Web Developer\My HTML Snippets&amp;quot;, where &amp;quot;C:\&amp;quot; is your OS drive.&lt;/p&gt;
  424.  
  425. &lt;p&gt;If you encounter any difficulties with the installer, check out this &lt;a href=&quot;http://weblogs.asp.net/jacqueseloff/archive/2009/06/09/troubleshooting-the-mvc-installer-for-visual-studio-2010-beta-1.aspx&quot;&gt;blog post by Jacques Eloff&lt;/a&gt;. He developed the installer and hopefully his post can help you out. Luckily for me everything proceeded with no problems. Booting up Visual Studio 2010 Beta 1 for the first time, I was presented with the new start screen:&lt;/p&gt;
  426.  
  427. &lt;p&gt;&lt;img src=&quot;/custom/files/old/1-vs2010-first-boot-1024x736.jpg&quot; alt=&quot;IMAGE&quot;&gt;
  428. &lt;img src=&quot;/custom/files/old/2-creating-mvc-project-150x150.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  429.  
  430. &lt;p&gt;From here, you can launch the new New Project dialog either via the File menu or by clicking &amp;quot;Projects&amp;quot; on the left side of the startup screen and then clicking the &amp;quot;New Project&amp;quot; icon. If the Asp.Net MVC 1.1 installer has been correctly installed, you will find a &amp;quot;ASP.NET MVC Web Application&amp;quot; entry under the &amp;quot;Web&amp;quot; category in the New Project dialog. Fiddle with the Name, Location, and Solution Name as always and then click OK to create your application.&lt;/p&gt;
  431.  
  432. &lt;p&gt;&lt;img src=&quot;/custom/files/old/3-create-test-project-150x150.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  433.  
  434. &lt;p&gt;After clicking OK, we would expect to be presented with the dialog that asks us if we want to create a test project for our new MVC application and indeed it does appear. MSTest is listed by default as always and was the only option available to me even though I do have MBUnit and xUnit.net showing up in this dialog in VS2008. If anyone knows an easy way to get the other test frameworks working with this dialog, please leave a comment or drop me an email. To me this isn&amp;#39;t a big deal, as I prefer to setup my test projects manually and don&amp;#39;t see a lot of value in the dialog, but I&amp;#39;m sure some people prefer to use it. For the sake of expediency I went and ahead and let Visual Studio create an MSTest project (better than nothing, right? maybe?) and proceeded into the project and opened up a view only to hit my next stumbling block...&lt;/p&gt;
  435.  
  436. &lt;p&gt;&lt;img src=&quot;/custom/files/old/4-project-created-1024x736.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  437.  
  438. &lt;p&gt;The culprit here is that in Visual Studio 2008 I use a dark theme based off the Vibrant Ink-ish theme &lt;a href=&quot;http://blog.wekeroad.com/blog/textmate-theme-for-visual-studio-take-2/&quot;&gt;Rob Conery posted a long time ago&lt;/a&gt;. Evidently the upgrade process was able to transfer over most of my foreground preferences but none of my background preferences. This left me with light text on a white background. A quick hop skip &amp;amp; a jump through &amp;quot;Tools&amp;quot; &amp;gt; &amp;quot;Import and Export Settings...&amp;quot; allowed me to import the defaults, thus making my color scheme readable, if a bit too vanilla.&lt;/p&gt;
  439.  
  440. &lt;p&gt;Now that my application is loaded up and legible, I decided I would make a couple small changes to the application and take some of the old (and new) features for a test drive to see how they did. First I tried out controller scaffolding: right-click on the MVC application&amp;#39;s Controllers folder and select &amp;quot;Add &amp;gt; Controller...&amp;quot;. That worked fine and was able to generate the CRUD scaffolding I requested. Next I tried automatic view generation: right-click anywhere inside of an action and select &amp;quot;Add View...&amp;quot;. I was pleased to find that neither of these features had been lost and were working as expected.&lt;/p&gt;
  441.  
  442. &lt;p&gt;&lt;img src=&quot;/custom/files/old/9-choosing-actionlink-snippet-300x206.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  443.  
  444. &lt;p&gt;So now I&amp;#39;ve created a ProductController with various actions as well as a basic view for the controller&amp;#39;s Index action, but I don&amp;#39;t have any way to navigate to that action except typing the URL in by hand. Thinking this might be a good time to try out the new snippets, I opened up the Site.Master view and added a new &amp;lt;li&amp;gt;&amp;lt;/li&amp;gt; to the navigation element. Having not really used snippets much before, I was temporarily lost as I expected to find them in the Toolbox (were they not in there at one point?). Luckily they were even easier to find than that, all I had to do was right-click. &lt;em&gt;(On a side note, this makes it much more likely that I&amp;#39;ll use them - the quickest way to get me to not use a Visual Studio feature is to make me deal with the horribly slow loading toolbar).&lt;/em&gt; The context-menu inside of views has an &amp;quot;Insert Snippet...&amp;quot; entry that, once selected, will give you three options:  ASP.NET, HTML, and My HTML Snippets. The snippets we installed earlier were placed in our user folder, which means Visual Studio will automatically detect them and load them in to the &amp;quot;My HTML Snippets&amp;quot; folder. Selecting that folder presents you with a list of many basic HTML helper snippets.&lt;/p&gt;
  445.  
  446. &lt;p&gt;In this case I wanted to use the first one, actionlink, to create a new call to Html.ActionLink(...). Selecting it then inserted the Html helper text as I would expect, and highlighted the arguments for the link&amp;#39;s text and action also as I would expect. I did notice that the snippet doesn&amp;#39;t automatically insert a placeholder for specifying which controller the actionlink refers to and adding a comma after the last argument did not bring up the list of overloads for Html.ActionLink that I expected to see.&lt;/p&gt;
  447.  
  448. &lt;p&gt;With that done I hit F5 and was able to browse to my Product controller&amp;#39;s Index action, confirming that Asp.Net MVC is indeed working fine with Visual Studio 2010. It looks like there are still some kinks to work out, but it is already close enough that I feel confident that Beta 2&amp;#39;s integration should be quite good. &lt;/p&gt;
  449. </content>
  450. </entry>
  451. <entry>
  452.   <title>DevPocalypse : A *Basic* Asp.Net MVC + jQuery Game</title>
  453.   <link href="http://www.squaredroot.com/2008/12/12/devpocalypse-basic-multiplayer-mvc-jquery-ajax-sample/"/>
  454.   <updated>2008-12-12T00:00:00+00:00</updated>
  455.   <id>http://www.squaredroot.com/2008/12/12/devpocalypse-basic-multiplayer-mvc-jquery-ajax-sample</id>
  456.   <content type="html">&lt;p&gt;Last weekend I had the privilege of speaking at the second &lt;a href=&quot;http://www.novacodecamp.org/&quot;&gt;Northern Virginia CodeCamp&lt;/a&gt; of the year, thanks to an invitation from &lt;a href=&quot;http://thequeue.net/blog/&quot;&gt;Jeff Schoolcraft&lt;/a&gt;. For those of you who were able to make it to the event, thanks for attending, and make sure to &lt;a href=&quot;http://codecampevals.com/&quot;&gt;fill out an eval&lt;/a&gt;! For those of you who didn&amp;#39;t make it (or those who did and want a deeper peek at the code I presented), feel free to check out the code to my sample app &amp;amp; posted below.&lt;/p&gt;
  457.  
  458. &lt;h2&gt;DevPocalypse (ASP.NET MVC + jQuery = Simple Multiplayer Action)&lt;/h2&gt;
  459.  
  460. &lt;p&gt;The basic idea of the game is that multiple players can exist on a grid (a &amp;quot;screen&amp;quot;) and move around to unoccupied spaces (&amp;quot;blocks&amp;quot;) adjacent to their current location. I had grand hopes of being able to click another player to attack them and include some basic chat, but alas, it was not meant to be. At least not for this presentation. My hope is to continue working on this as a single sample app I can use to illustrate various MVC techniques for future speaking engagements.&lt;/p&gt;
  461.  
  462. &lt;p&gt;Let&amp;#39;s take a gander at what the app looks like when it is running:&lt;/p&gt;
  463.  
  464. &lt;p&gt;&lt;img src=&quot;/custom/files/old/DevPocalypse-Screenshot_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  465.  
  466. &lt;p&gt;Yup, like I said: basic. So those two little guys are players. You can&amp;#39;t see it in a screenshot, but when you click a square next to where &lt;em&gt;your&lt;/em&gt; player is standing, jQuery will smoothly animate the transition of your character from the current block to the new block. What is even neater is that when a player on a different computer moves &lt;em&gt;their&lt;/em&gt; player, you also see the same jQuery animation execute. How are we doing this? Well first we use a simple polling script (from Game.js):&lt;/p&gt;
  467.  
  468. &lt;script src=&quot;https://gist.github.com/4001183.js?file=Example-1.js&quot;&gt; &lt;/script&gt;
  469.  
  470. &lt;p&gt;Ultimately, this code calls an action named GetCurrentScreen on the GameController. Currently this executes twice a second so as to be nice and responsive, but of course I have no idea how that would handle under load. Here is the entire GameController class:&lt;/p&gt;
  471.  
  472. &lt;script src=&quot;https://gist.github.com/4001183.js?file=Example-2.cs&quot;&gt; &lt;/script&gt;
  473.  
  474. &lt;p&gt;Pretty simple, huh? Note how nice and easy it was to return an anonymous type as a JSON (JavaScript Object Notation) object via the Json(obj) method. Finally, here is the bit of Game.js that performs the actual animation (this is done in a loop updating all characters – hence the &lt;strong&gt;&lt;em&gt;id&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;c&lt;/em&gt;&lt;/strong&gt; variables):&lt;/p&gt;
  475.  
  476. &lt;script src=&quot;https://gist.github.com/4001183.js?file=Example-3.js&quot;&gt; &lt;/script&gt;
  477.  
  478. &lt;p&gt;Gotta love jQuery. :-) There is plenty more to look at in the source, so feel free to download it, check it out, play around with it - use it for whatever you want.&lt;/p&gt;
  479.  
  480. &lt;p&gt;Thanks, and I hope to see you at the next CodeCamp!&lt;/p&gt;
  481.  
  482. &lt;p&gt;&lt;a href=&quot;/custom/files/old/DevPocalypse.zip&quot;&gt;DevPocalypse.zip&lt;/a&gt;&lt;/p&gt;
  483. </content>
  484. </entry>
  485. <entry>
  486.   <title>MVC/jQuery Presentation at NoVa CodeCamp - Dec. 6</title>
  487.   <link href="http://www.squaredroot.com/2008/11/24/mvc-jquery-presentation-at-nova-codecamp-december-6-2008/"/>
  488.   <updated>2008-11-24T00:00:00+00:00</updated>
  489.   <id>http://www.squaredroot.com/2008/11/24/mvc-jquery-presentation-at-nova-codecamp-december-6-2008</id>
  490.   <content type="html">&lt;p&gt;&lt;img src=&quot;/custom/files/old/NoVaCodeCamp.gif&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  491.  
  492. &lt;p&gt;&lt;a href=&quot;http://thequeue.net/blog/&quot;&gt;Jeff Schoolcraft&lt;/a&gt; was kind enough to ask me to speak at this year&amp;#39;s second &lt;a href=&quot;http://novacodecamp.org/&quot;&gt;NoVa CodeCamp&lt;/a&gt;. It is being held in two weeks on Saturday, December 6th at the Microsoft Technology Center in Reston, VA [&lt;a href=&quot;http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=12012+Sunset+Hills+Rd.++Reston,+VA+20190&amp;amp;sll=37.0625,-95.677068&amp;amp;sspn=51.089971,79.101563&amp;amp;ie=UTF8&amp;amp;z=16&amp;amp;g=12012+Sunset+Hills+Rd.++Reston,+VA+20190&amp;amp;iwloc=addr&quot;&gt;map&lt;/a&gt;]. If you&amp;#39;re interested in attending, please make sure you &lt;a href=&quot;https://www.clicktoattend.com/invitation.aspx?code=131469&quot;&gt;register&lt;/a&gt; soon!&lt;/p&gt;
  493.  
  494. &lt;p&gt;I don&amp;#39;t yet have word on the final presentation schedule, but here is the abstract for the presentation I will be giving:&lt;/p&gt;
  495.  
  496. &lt;blockquote&gt;
  497. **Creating an AJAX MMORPG With jQuery &amp; Asp.Net MVC**
  498.  
  499. C&#39;mon, it&#39;s Saturday, let&#39;s take a break from those enterprise class systems and make something that we can enjoy ourselves! Over the past several years users have become increasingly conditioned to expect a fast, responsive UI that communicates changes in a clear manner - even in the apps we build at our day jobs. We&#39;ll see how jQuery allows us to build such a UI using AJAX and animations in a quick, cross-platform manner. We&#39;ll also see how ASP.Net MVC makes it easier than ever to integrate with AJAX frameworks like jQuery. By the end of our session, we&#39;ll even have a fun little game to play!
  500. &lt;/blockquote&gt;
  501.  
  502. &lt;p&gt;In the following two weeks I&amp;#39;ll be posting the code I&amp;#39;m currently creating as the basis of this presentation to my blog so that everyone can download it and check it out. I hope to see some of you at the CodeCamp!&lt;/p&gt;
  503. </content>
  504. </entry>
  505. <entry>
  506.   <title>My PDC 2008 Agenda</title>
  507.   <link href="http://www.squaredroot.com/2008/10/23/pdc-2008-agenda/"/>
  508.   <updated>2008-10-23T00:00:00+00:00</updated>
  509.   <id>http://www.squaredroot.com/2008/10/23/pdc-2008-agenda</id>
  510.   <content type="html">&lt;p&gt;This Saturday I&amp;#39;ll be headed off to sunny Los Angeles for Microsoft&amp;#39;s &lt;a href=&quot;http://microsoftpdc.com&quot;&gt;Professional Developer Conference 2008&lt;/a&gt;. This is the first time I&amp;#39;ve gone and I&amp;#39;m really looking forward to it. I&amp;#39;m staying at &lt;a href=&quot;http://www.figueroahotel.com&quot;&gt;Hotel Figeuroa&lt;/a&gt;, only a couple blocks from the &lt;a href=&quot;http://www.lacclink.com&quot;&gt;Los Angeles Convention Center&lt;/a&gt;, and I&amp;#39;ve posted my tentative session agenda (more for my own reference than anything else) below. If anyone else would like to meet up for drinks after the sessions, &lt;a href=&quot;mailto:troygoode@gmail.com&quot;&gt;drop me an email&lt;/a&gt;.&lt;/p&gt;
  511.  
  512. &lt;h2&gt;Pre-Conference / Sunday Oct 26 2008&lt;/h2&gt;
  513.  
  514. &lt;ul&gt;
  515. &lt;li&gt;&lt;strong&gt;10:00 AM - 5:45 PM:&lt;/strong&gt; &lt;a href=&quot;http://microsoftpdc.com/Agenda/Preconference.aspx#creating-rich-internet-applications-with-silverlight&quot;&gt;Creating Rich Internet Applications with Silverlight&lt;/a&gt;&lt;/li&gt;
  516. &lt;/ul&gt;
  517.  
  518. &lt;h2&gt;Day One / Monday Oct 27 2008&lt;/h2&gt;
  519.  
  520. &lt;ul&gt;
  521. &lt;li&gt;&lt;strong&gt;8:30 AM - 11:00 AM:&lt;/strong&gt; Keynote&lt;/li&gt;
  522. &lt;li&gt;&lt;strong&gt;11:00 AM - 12:45 AM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/ES16/&quot;&gt;A Lap Around Cloud Services (Part 1)&lt;/a&gt;&lt;/li&gt;
  523. &lt;li&gt;&lt;strong&gt;12:45 PM - 1:45 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/PC47/&quot;&gt;Microsoft Expression Blend: Tips &amp;amp; Tricks&lt;/a&gt;&lt;/li&gt;
  524. &lt;li&gt;&lt;strong&gt;1:45 PM - 3:30 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/PC20/&quot;&gt;ASP.Net 4.0 Roadmap&lt;/a&gt;&lt;/li&gt;
  525. &lt;li&gt;&lt;strong&gt;3:30 PM - 5:15 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/BB01/&quot;&gt;A Lap Around Cloud Services (Part 2)&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/PC21/&quot;&gt;ASP.NET MVC: A New Framework for Building Web Applications&lt;/a&gt;&lt;/li&gt;
  526. &lt;li&gt;&lt;strong&gt;5:15 PM - 6:30 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/ES01/&quot;&gt;Developing and Deploying Your First Cloud Service&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL49/&quot;&gt;Microsoft .NET Framework: Overview and Applications for Babies&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL17/&quot;&gt;Windows Workflow Foundation 4.0: A First Look&lt;/a&gt;&lt;/li&gt;
  527. &lt;/ul&gt;
  528.  
  529. &lt;h2&gt;Day Two / Tuesday Oct 28 2008&lt;/h2&gt;
  530.  
  531. &lt;ul&gt;
  532. &lt;li&gt;&lt;strong&gt;3:30 AM - 12:45 PM:&lt;/strong&gt; Keynote&lt;/li&gt;
  533. &lt;li&gt;&lt;strong&gt;12:45 PM - 1:45 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/PC24/&quot;&gt;Windows 7: Welcome to the Windows 7 Desktop&lt;/a&gt;&lt;/li&gt;
  534. &lt;li&gt;&lt;strong&gt;1:45 PM - 3:30 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/ES04/&quot;&gt;Essential Cloud Storage Services&lt;/a&gt;&lt;/li&gt;
  535. &lt;li&gt;&lt;strong&gt;3:30 PM - 5:15 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/PC33/&quot;&gt;Microsoft Visual Studio: Easing ASP.NET Web Deployment&lt;/a&gt;&lt;/li&gt;
  536. &lt;li&gt;&lt;strong&gt;5:15 PM - 6:30 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL20/&quot;&gt;Entity Framework Futures&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/PC31/&quot;&gt;ASP.NET and JQuery&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/ES02/&quot;&gt;Architecting Services for the Cloud&lt;/a&gt;&lt;/li&gt;
  537. &lt;/ul&gt;
  538.  
  539. &lt;h2&gt;Day Three / Wednesday Oct 29 2008&lt;/h2&gt;
  540.  
  541. &lt;ul&gt;
  542. &lt;li&gt;&lt;strong&gt;8:30 AM - 10:30 AM:&lt;/strong&gt; Keynote&lt;/li&gt;
  543. &lt;li&gt;&lt;strong&gt;10:30 AM - 12:00 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL06/&quot;&gt;WCF 4.0: Building WCF Services with WF in Microsoft .NET 4.0&lt;/a&gt;&lt;/li&gt;
  544. &lt;li&gt;&lt;strong&gt;12:00 PM - 1:15 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL43/&quot;&gt;Microsoft XNA Game Studio: An Overview&lt;/a&gt;&lt;/li&gt;
  545. &lt;li&gt;&lt;strong&gt;1:15 PM - 3:00 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL18/&quot;&gt;&amp;quot;Oslo&amp;quot;: Customizing and Extending the Visual Design Experience&lt;/a&gt;&lt;/li&gt;
  546. &lt;li&gt;&lt;strong&gt;3:00 PM - 4:45 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/ES03/&quot;&gt;A Day in the Life of a Cloud Service Developer&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/PC55/&quot;&gt;Oomph: A Microformat Toolkit&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL28/&quot;&gt;&amp;quot;Oslo&amp;quot;: Repository and Models&lt;/a&gt;&lt;/li&gt;
  547. &lt;li&gt;&lt;strong&gt;4:45 PM - 6:00 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL23-R/&quot;&gt;A Lap around &amp;quot;Oslo&amp;quot;&lt;/a&gt;&lt;/li&gt;
  548. &lt;/ul&gt;
  549.  
  550. &lt;h2&gt;Day Four / Thursday Oct 30 2008&lt;/h2&gt;
  551.  
  552. &lt;ul&gt;
  553. &lt;li&gt;&lt;strong&gt;8:30 AM - 10:15 AM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/TL04/&quot;&gt;WCF: Developing RESTful Services&lt;/a&gt;&lt;/li&gt;
  554. &lt;li&gt;&lt;strong&gt;10:15 AM - 12:00 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/SYMP05/&quot;&gt;Services Symposium: Enterprise Grade Cloud Applications&lt;/a&gt;&lt;/li&gt;
  555. &lt;li&gt;&lt;strong&gt;12:00 PM - 1:45 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/ES17/&quot;&gt;Cloud Computing: Programming in the Cloud&lt;/a&gt;&lt;/li&gt;
  556. &lt;li&gt;&lt;strong&gt;1:45 PM - 3:00 PM:&lt;/strong&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/PC32/&quot;&gt;ASP.NET AJAX Futures&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;http://channel9.msdn.com/pdc2008/BB27/&quot;&gt;Workflow Services: Orchestrating Services and Business Processes Using Cloud-Based Workflow&lt;/a&gt;&lt;/li&gt;
  557. &lt;/ul&gt;
  558. </content>
  559. </entry>
  560. <entry>
  561.   <title>ASP.Net MVC Goes Beta!</title>
  562.   <link href="http://www.squaredroot.com/2008/10/16/aspnet-mvc-beta-release/"/>
  563.   <updated>2008-10-16T00:00:00+00:00</updated>
  564.   <id>http://www.squaredroot.com/2008/10/16/aspnet-mvc-beta-release</id>
  565.   <content type="html">&lt;p&gt;I discovered via &lt;a href=&quot;http://www.dotnetkicks.com/aspnet/ASP_net_MVC_goes_Beta&quot;&gt;DotNetKicks&lt;/a&gt; this afternoon that the ASP.Net MVC framework&amp;#39;s beta release is now &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?familyid=a24d1e00-cd35-4f66-baa0-2362bdde0766&amp;amp;displaylang=en&amp;amp;tm&quot;&gt;available for download from Microsoft.com&lt;/a&gt;. No release or source code is yet available from the &lt;a href=&quot;http://www.codeplex.com/aspnet&quot;&gt;CodePlex project&lt;/a&gt;, but I expect we&amp;#39;ll see it there soon enough. Congratulations to the team at Microsoft, RTM is knocking at the door!&lt;/p&gt;
  566.  
  567. &lt;p&gt;&lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?familyid=a24d1e00-cd35-4f66-baa0-2362bdde0766&amp;amp;displaylang=en&amp;amp;tm&quot;&gt;Download ASP.NET MVC Beta.&lt;/a&gt;&lt;/p&gt;
  568. </content>
  569. </entry>
  570. <entry>
  571.   <title>Introduction to ASP.Net MVC for Alt.Net DC Tonight</title>
  572.   <link href="http://www.squaredroot.com/2008/09/24/altdotnet-presentation-20080924/"/>
  573.   <updated>2008-09-24T00:00:00+00:00</updated>
  574.   <id>http://www.squaredroot.com/2008/09/24/altdotnet-presentation-20080924</id>
  575.   <content type="html">&lt;p&gt;Anyone in the Washington, DC area who is interested in an introductory peek at Microsoft&amp;#39;s new ASP.Net MVC platform is invited to come out to tonight&amp;#39;s Alt.Net meeting. I will be presenting the front-to-back basics you need to know to get started in developing with the MVC framework, using a MVC blog engine as our use case. Details about the when/where below. Many thanks to Matthew Podwysocki for asking me to speak tonight; it is a great privilege.&lt;/p&gt;
  576.  
  577. &lt;p&gt;&lt;strong&gt;When:&lt;/strong&gt;&lt;/p&gt;
  578.  
  579. &lt;p&gt;September 24, 2008 - 7PM to 9PM&lt;/p&gt;
  580.  
  581. &lt;p&gt;&lt;strong&gt;Where:&lt;/strong&gt;&lt;/p&gt;
  582.  
  583. &lt;p&gt;&lt;a href=&quot;http://www.cynergysystems.com/&quot;&gt;Cynergy Systems Inc.&lt;/a&gt;&lt;br&gt;
  584. 1600 K St NW&lt;br&gt;
  585. Suite 300&lt;br&gt;
  586. Washington, DC 20006&lt;/p&gt;
  587.  
  588. &lt;p&gt;&lt;a href=&quot;http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=1600+K+St+NW,+Washington,+DC+20006&amp;amp;sll=38.880459,-77.109452&amp;amp;sspn=0.012444,0.027895&amp;amp;ie=UTF8&amp;amp;z=16&quot;&gt;Show in Google Maps.&lt;/a&gt;&lt;/p&gt;
  589.  
  590. &lt;p&gt;&lt;strong&gt;More Info:&lt;/strong&gt;&lt;/p&gt;
  591.  
  592. &lt;p&gt;&lt;a href=&quot;http://codebetter.com/blogs/matthew.podwysocki/archive/2008/09/08/dc-alt-net-9-24-2008-building-asp-net-mvc-applications-with-troy-goode.aspx&quot;&gt;Matthew Podwysocki&amp;#39;s blog post&lt;/a&gt;&lt;/p&gt;
  593. </content>
  594. </entry>
  595. <entry>
  596.   <title>Introduction to ASP.Net MVC for Alt.Net DC - Presentation Materials</title>
  597.   <link href="http://www.squaredroot.com/2008/09/24/altdotnet-presentation-20080924-materials/"/>
  598.   <updated>2008-09-24T00:00:00+00:00</updated>
  599.   <id>http://www.squaredroot.com/2008/09/24/altdotnet-presentation-20080924-materials</id>
  600.   <content type="html">&lt;p&gt;I just got back from my ASP.Net MVC Presentation for tonight&amp;#39;s DC Alt.Net meeting and I had a great time. I hope everyone got a good feel for what it takes to develop an application using the MVC framework. Please don&amp;#39;t hesitate to &lt;a href=&quot;mailto:troygoode@gmail.com&quot;&gt;email me&lt;/a&gt; if you have any questions. Also I owe a big thanks to &lt;a href=&quot;http://codebetter.com/blogs/matthew.podwysocki/default.aspx&quot;&gt;Matthew Podwysocki&lt;/a&gt; for inviting me to speak. Thanks Matt, I really enjoyed the opportunity.&lt;/p&gt;
  601.  
  602. &lt;p&gt;I promised that I would post the project that we created tonight (a basic blog engine), which you can now find linked below. There are three projects in the solution:&lt;/p&gt;
  603.  
  604. &lt;ul&gt;
  605. &lt;li&gt;&lt;strong&gt;MvcTutorials.Blog.Domain:&lt;/strong&gt; This project has the Comment &amp;amp; Post entities, as well as the repositories used to populate them.&lt;/li&gt;
  606. &lt;li&gt;&lt;strong&gt;MvcTutorials.Blog.Domain.Bootstrap:&lt;/strong&gt; This project adds random data to the blog database for testing.&lt;/li&gt;
  607. &lt;li&gt;&lt;strong&gt;MvcTutorials.Blog.ReferenceWebsite:&lt;/strong&gt; This is the MVC website I created prior to the meeting to decide what I was going to present and how long it would take to do it. This is where you&amp;#39;ll find the code we wrote tonight.&lt;/li&gt;
  608. &lt;/ul&gt;
  609.  
  610. &lt;p&gt;If you want to run the project, make sure you have SQL Server Express installed and create a database named &amp;quot;MvcTutorial-Blog&amp;quot;. Afterward you can run the &amp;quot;MvcTutorials.Blog.Domain.Bootstrap&amp;quot; project to insert test data and run the website project.&lt;/p&gt;
  611.  
  612. &lt;p&gt;Be sure to let me know if there are any questions or comments about tonight&amp;#39;s presentation or this post&amp;#39;s code!&lt;/p&gt;
  613.  
  614. &lt;p&gt;&lt;a href=&quot;/custom/files/old/MvcTutorial-Blog.zip&quot;&gt;MvcTutorial-Blog.zip&lt;/a&gt;&lt;/p&gt;
  615. </content>
  616. </entry>
  617. <entry>
  618.   <title>MVC Membership - Preview 5</title>
  619.   <link href="http://www.squaredroot.com/2008/09/06/mvc-membership-preview-5/"/>
  620.   <updated>2008-09-06T00:00:00+00:00</updated>
  621.   <id>http://www.squaredroot.com/2008/09/06/mvc-membership-preview-5</id>
  622.   <content type="html">&lt;p class=&quot;warning&quot;&gt;This post is out of date. Please reference this project&#39;s &lt;a href=&quot;https://github.com/troygoode/membershipstarterkit&quot;&gt;GitHub page&lt;/a&gt; for the latest code.&lt;/p&gt;
  623.  
  624. &lt;p&gt;Last weekend I posted a release of the MVC Membership Starter Kit that targets &lt;a href=&quot;http://haacked.com/archive/2008/08/29/asp.net-mvc-codeplex-preview-5-released.aspx&quot;&gt;Preview 5 of the ASP.Net MVC framework&lt;/a&gt;. There was no packaged release targeting &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2008/07/14/asp-net-mvc-preview-4-release-part-1.aspx&quot;&gt;Preview 4&lt;/a&gt; (though if you &lt;a href=&quot;http://www.codeplex.com/MvcMembership/SourceControl/ListDownloadableCommits.aspx&quot;&gt;downloaded the latest source&lt;/a&gt;, it worked), so this release essentially packages the changes from both previews.&lt;/p&gt;
  625.  
  626. &lt;h2&gt;Why does the MVC Membership Starter Kit still exist?&lt;/h2&gt;
  627.  
  628. &lt;p&gt;The biggest change affecting the MVC Membership Starter Kit is that the default ASP.Net MVC Web Application project includes &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2008/07/14/asp-net-mvc-preview-4-release-part-1.aspx&quot;&gt;login/logout, register, and change password functionality as of Preview 4&lt;/a&gt;. This is great and I&amp;#39;m glad to see them do it. It is my hope they will eventually include membership administration functionality as well. For now, however, they haven&amp;#39;t included it. This leaves three main features that are now driving the existence of this project:&lt;/p&gt;
  629.  
  630. &lt;ul&gt;
  631. &lt;li&gt;&lt;strong&gt;Membership Administration:&lt;/strong&gt; What good is registration, login, and logout if a site&amp;#39;s owner cannot change a user&amp;#39;s roles or manage their user base? While Visual Studio&amp;#39;s &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/yy40ytx0.aspx&quot;&gt;Web Site Administration Tool&lt;/a&gt; covers most of your bases during development, it isn&amp;#39;t a real option for use by web site administrators in a production application.&lt;/li&gt;
  632. &lt;li&gt;&lt;strong&gt;OpenID Integration:&lt;/strong&gt; Preview 4&amp;#39;s built-in login functionality only covers the use of standard username/password authentication. It seems likely that this will continue, as I am not aware of any plans for official &lt;a href=&quot;http://openid.net/&quot;&gt;OpenID&lt;/a&gt; support within the .Net framework. We are using &lt;a href=&quot;http://code.google.com/p/dotnetopenid/&quot;&gt;Andrew Arnott &amp;amp; co&amp;#39;s DotNetOpenId&lt;/a&gt; project to help you let your users log in using OpenID.&lt;/li&gt;
  633. &lt;li&gt;&lt;strong&gt;WindowsLive LiveID Integration:&lt;/strong&gt; &lt;a href=&quot;http://blog.maartenballiauw.be/&quot;&gt;Maarten&lt;/a&gt;&amp;#39;s &lt;a href=&quot;http://dev.live.com/liveid/&quot;&gt;LiveID&lt;/a&gt; integration has unfortunately not made this release. I anticipate that it will be available again for the next release, which will target &lt;a href=&quot;http://haacked.com/archive/2008/09/05/mvcfutures-and-asp.net-mvc-beta.aspx&quot;&gt;the first beta release of ASP.Net MVC&lt;/a&gt;.&lt;/li&gt;
  634. &lt;/ul&gt;
  635.  
  636. &lt;h2&gt;What has changed?&lt;/h2&gt;
  637.  
  638. &lt;ul&gt;
  639. &lt;li&gt;&lt;strong&gt;No more login/logout/password retrieval.&lt;/strong&gt; Because the AccountController and its views are now included by default in new projects, the need for this functionality has gone away.&lt;/li&gt;
  640. &lt;li&gt;&lt;strong&gt;Less assemblies to reference.&lt;/strong&gt; Rather than the MembershipAdministrationController and other code being compiled into a separate assembly that you must include, you now drop the controllers directly into your web app. This allows you to easily change the code as your project evolves. The starter kit&amp;#39;s implementation is really just a starting point that you can build off of.&lt;/li&gt;
  641. &lt;li&gt;&lt;strong&gt;Controllers are split.&lt;/strong&gt; In previous releases the OpenID and WindowsLive login functionality was included in the MembershipAuthenticationController. The OpenID functionality has since been moved into a separate controller with separate views. This was done because (a) the MembershipAuthenticationController no longer exists and (b) moving forward more of the pieces of this kit will be separated from each other so that you can include them a la carte.&lt;/li&gt;
  642. &lt;/ul&gt;
  643.  
  644. &lt;h2&gt;Download&lt;/h2&gt;
  645.  
  646. &lt;p&gt;You can download the Preview 5 release of the MVC Membership Starter Kit from CodePlex:&lt;/p&gt;
  647.  
  648. &lt;p&gt;&lt;a href=&quot;http://www.codeplex.com/MvcMembership/Release/ProjectReleases.aspx?ReleaseId=16809#ReleaseFiles&quot;&gt;http://www.codeplex.com/MvcMembership/Release/ProjectReleases.aspx?ReleaseId=16809#ReleaseFiles&lt;/a&gt;&lt;/p&gt;
  649. </content>
  650. </entry>
  651. <entry>
  652.   <title>PagedList Strikes Back</title>
  653.   <link href="http://www.squaredroot.com/2008/07/08/pagedlist-strikes-back/"/>
  654.   <updated>2008-07-08T00:00:00+00:00</updated>
  655.   <id>http://www.squaredroot.com/2008/07/08/pagedlist-strikes-back</id>
  656.   <content type="html">&lt;p class=&quot;warning&quot;&gt;There is an updated version of the PagedList&amp;lt;T&amp;gt; code available &lt;a href=&quot;https://github.com/troygoode/pagedlist&quot;&gt;on GitHub&lt;/a&gt;.&lt;/p&gt;
  657.  
  658. &lt;p&gt;A few months ago I posted about &lt;a href=&quot;/2008/04/08/updated-pagedlist-class/&quot;&gt;my changes&lt;/a&gt; to &lt;a href=&quot;http://blog.wekeroad.com/2007/12/10/aspnet-mvc-pagedlistt/&quot;&gt;Rob Conery&amp;#39;s PagedList&lt;/a&gt; class. Since writing that article many comments have been left about how to further improve the design, which I have since incorporated into a new, further improved PagedList class. For those who aren&amp;#39;t familiar, the PagedList class allows scenarios such as the following:&lt;/p&gt;
  659.  
  660. &lt;script src=&quot;https://gist.github.com/4001462.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  661.  
  662. &lt;p&gt;So in the above scenario (an example MVC action), if you had a list of 30 products with IDs 1-30 and passed in a pageIndex of 2 you would pass the products with IDs 21-30 into your view. Best of all it uses IQueryable, so if you pass a LINQ expression or IQueryable result into ToPagedList(...) it will do the filtering on the database side! Take a look at the new improved PagedList &lt;a href=&quot;https://github.com/troygoode/pagedlist&quot;&gt;on GitHub&lt;/a&gt;.&lt;/p&gt;
  663.  
  664. &lt;p&gt;&lt;strong&gt;Changes Since Previous Version:&lt;/strong&gt;&lt;/p&gt;
  665.  
  666. &lt;ul&gt;
  667. &lt;li&gt;&lt;strong&gt;Changed &amp;quot;TotalPages&amp;quot; property to &amp;quot;PageCount&amp;quot;.&lt;/strong&gt; This was done to more clearly illustrate the purpose of this property (more in line with the standard List&amp;lt;T&amp;gt; .Count property).&lt;/li&gt;
  668. &lt;li&gt;&lt;strong&gt;Changed &amp;quot;TotalCount&amp;quot; property to &amp;quot;TotalItemCount&amp;quot;.&lt;/strong&gt; This was done to differentiate between Pages and Items more clearly.&lt;/li&gt;
  669. &lt;li&gt;&lt;strong&gt;Switched &amp;quot;PageIndex&amp;quot; back to being a zero-based index, rather than one-based.&lt;/strong&gt; The PageIndex was set to be one-based because the most common use-case that I could think of, outputting a pager (i.e.: Previous - 1 - 2 - 3 - Next), was one-based and it would be nice to not have to do &amp;quot;obj.PageIndex + 1&amp;quot; everywhere. This was probably a poor decision. Some people found it confusing and &lt;a href=&quot;/2008/04/08/updated-pagedlist-class/#comment-152106122&quot;&gt;others found that it didn&amp;#39;t work with the standard .Net DataPager&lt;/a&gt;.&lt;/li&gt;
  670. &lt;li&gt;&lt;strong&gt;Added &amp;quot;PageNumber&amp;quot; property.&lt;/strong&gt; As suggested &lt;a href=&quot;/2008/04/08/updated-pagedlist-class/#comment-152106104&quot;&gt;via comment&lt;/a&gt; on my previous post, PageNumber is just PageIndex + 1.&lt;/li&gt;
  671. &lt;li&gt;&lt;strong&gt;Treat all data as IQueryable for the duration of class initialization.&lt;/strong&gt; Tgmdbm, a frequent contributer on the &lt;a href=&quot;http://forums.asp.net/1146.aspx&quot;&gt;ASP.Net MVC forums&lt;/a&gt;, pointed out &lt;a href=&quot;/2008/04/08/updated-pagedlist-class/#comment-152106101&quot;&gt;some good reasons&lt;/a&gt; why everything should be treated as IQueryable before the .Skip(x).Take(y). I&amp;#39;m not 100% sold that treating it as IEnumerable would also work for IQueryable objects (since IQueryable supports IEnumerable), but to be safe I have defaulted everything to using IQueryable. You can still pass in a strict IEnumerable, but it will be converted to IQueryable for the duration of the PagedList class initialization process.&lt;/li&gt;
  672. &lt;li&gt;&lt;strong&gt;Tested with &lt;a href=&quot;http://www.codeplex.com/xunit&quot;&gt;xUnit.net&lt;/a&gt;.&lt;/strong&gt; While the PagedList class isn&amp;#39;t exactly rocket science, I want to strive to improve the quality of the code that I&amp;#39;m presenting to the community. I also enjoyed having an excuse to try out xUnit&amp;#39;s data-driven testing using the [Theory] attribute (similar to MbUnit&amp;#39;s [RowTest]) for the first time. Not much has been written about it, but I was able to find &lt;a href=&quot;http://blog.benhall.me.uk/2008/01/introduction-to-xunitnet-extensions.html&quot;&gt;some examples from Ben Hall&lt;/a&gt; which got me up and testing quickly.&lt;/li&gt;
  673. &lt;/ul&gt;
  674.  
  675. &lt;p&gt;A big thanks to everyone who has thrown their two cents in to help improve this small but useful class!&lt;/p&gt;
  676. </content>
  677. </entry>
  678. <entry>
  679.   <title>MVC Controller Action Security Hole</title>
  680.   <link href="http://www.squaredroot.com/2008/07/08/mvc-controller-action-security-hole/"/>
  681.   <updated>2008-07-08T00:00:00+00:00</updated>
  682.   <id>http://www.squaredroot.com/2008/07/08/mvc-controller-action-security-hole</id>
  683.   <content type="html">&lt;p&gt;The latest of &lt;a href=&quot;http://weblogs.asp.net/stephenwalther/&quot;&gt;Stephen Walther&lt;/a&gt;&amp;#39;s invaluable &lt;a href=&quot;http://weblogs.asp.net/stephenwalther/archive/tags/Tips/default.aspx&quot;&gt;ASP.Net MVC Tip series&lt;/a&gt; points out a MVC scenario that was previously unknown to me: &lt;a href=&quot;http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx&quot;&gt;passing cookies and server variables into controllers as action parameters&lt;/a&gt;. While the idea is neat, &lt;a href=&quot;http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6377484&quot;&gt;a comment left by Francois Ward&lt;/a&gt; echoed my immediate skepticism over whether this could be safe. After playing around I believe I have confirmed my suspicions that making use of this capability is a Very Bad Idea.&lt;/p&gt;
  684.  
  685. &lt;p&gt;I&amp;#39;ll let Francois&amp;#39; comment explain the problem (emphasis mine):&lt;/p&gt;
  686.  
  687. &lt;blockquote&gt;
  688. Tuesday, July 08, 2008 4:16 PM by Francois Ward
  689.  
  690. Hmm, I didn&#39;t look into it much, but is that -safe-? I mean, if the variables in the index function are filled up automatically... it would be ok if it was only one type (all cookies, or all server variables), but since you can mix and match, **whats to present me from forging a request with a cookie with the same name as the server variables**?
  691.  
  692. I mean, it is already possible to forge anything client-related, for obvious reason... but **forging info that potentially come from the server**? That seems...awkward...
  693.  
  694. (again, keep in mind this is just my first reaction, maybe if I think it through I&#39;ll realize what I just said is totally stupid :) )
  695. &lt;/blockquote&gt;
  696.  
  697. &lt;p&gt;Like Francois said, cookies are easily forged client-side anyway, but most developers tend to rely on the &lt;a href=&quot;http://en.wikipedia.org/wiki/Truthiness&quot;&gt;truthiness&lt;/a&gt; of our server variables, specifically those that don&amp;#39;t come over in the HTTP request. Let me demonstrate how the issue plays out.&lt;/p&gt;
  698.  
  699. &lt;p&gt;For our example I have created a method on the HomeController named Test that takes four parameters that match server variable names. Below are the descriptions of each from MSDN&amp;#39;s &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms524602.aspx&quot;&gt;IIS Server Variables&lt;/a&gt; article:&lt;/p&gt;
  700.  
  701. &lt;ul&gt;
  702. &lt;li&gt;&lt;strong&gt;REMOTE_ADDR&lt;/strong&gt; MSDN Says, &amp;quot;The IP address of the remote host that is making the request.&amp;quot;&lt;/li&gt;
  703. &lt;li&gt;&lt;strong&gt;LOGON_USER&lt;/strong&gt; MSDN Says, &amp;quot;The Windows account that the user is impersonating while connected to your Web server. Use REMOTE&lt;em&gt;USER, UNMAPPED&lt;/em&gt;REMOTE&lt;em&gt;USER, or AUTH&lt;/em&gt;USER to view the raw user name that is contained in the request header. The only time LOGON_USER holds a different value than these other variables is if you have an authentication filter installed.&amp;quot;&lt;/li&gt;
  704. &lt;li&gt;&lt;strong&gt;REQUEST_METHOD&lt;/strong&gt; MSDN Says, &amp;quot;The method used to make the request. For HTTP, this can be &lt;strong&gt;GET&lt;/strong&gt;, &lt;strong&gt;HEAD&lt;/strong&gt;, &lt;strong&gt;POST&lt;/strong&gt;, and so on.&amp;quot;&lt;/li&gt;
  705. &lt;li&gt;&lt;strong&gt;SERVER_NAME&lt;/strong&gt; The server&amp;#39;s host name, DNS alias, or IP address as it would appear in self-referencing URLs.&lt;/li&gt;
  706. &lt;/ul&gt;
  707.  
  708. &lt;p&gt;My biggest concern is &lt;strong&gt;LOGON_USER&lt;/strong&gt;. As described by MSDN this variable normally stores whatever the value of REMOTE&lt;em&gt;USER, UNMAPPED&lt;/em&gt;REMOTE&lt;em&gt;USER, or AUTH&lt;/em&gt;USER is, except when you have a third party authentication filter installed. The purpose of these authentication filters is to map the value of one of the above three request variables to a different local name. For example, you may be using a filter to map &amp;quot;DOMAINTroyGoode&amp;quot; to &amp;quot;DOMAIN-DMZStandardUser&amp;quot; and to map &amp;quot;DOMAINScottGuthrie&amp;quot; to &amp;quot;DOMAIN-DMZAdministrator&amp;quot;. If you are using such a filter and then add LOGON_USER as a parameter to one of your actions, you are suddenly opening up the ability for anyone to circumvent that authentication filter.&lt;/p&gt;
  709.  
  710. &lt;p&gt;Here is the action I have created:&lt;/p&gt;
  711.  
  712. &lt;script src=&quot;https://gist.github.com/4001511.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  713.  
  714. &lt;p&gt;And here is what this action will output without any fiddling:&lt;/p&gt;
  715.  
  716. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Unhacked_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  717.  
  718. &lt;p&gt;Now I&amp;#39;ll tweak the Url a bit:&lt;/p&gt;
  719.  
  720. &lt;blockquote&gt;
  721. First Url:
  722.  
  723. http://localhost:63260/Home/Test
  724.  
  725. Second Url:
  726.  
  727. http://localhost:63260/Home/Test?REMOTE_ADDR=Any.IP.I.Want&amp;LOGON_USER=YourDomainAdministrator&amp;REQUEST_METHOD=POST&amp;SERVER_NAME=microsoft.com
  728. &lt;/blockquote&gt;
  729.  
  730. &lt;p&gt;And voil&amp;agrave;, mischief achieved:&lt;/p&gt;
  731.  
  732. &lt;p&gt;&lt;img src=&quot;/custom/files/old/TotallyHaxxored_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  733.  
  734. &lt;p&gt;Now I&amp;#39;m no Kevin Mitnick, but I can assure you that if I can come up with something like this in an hour or so, a dedicated hacker that is probably far smarter than I will likely give you a lot of heartache if you make use of this feature. Have any &amp;quot;developer mode checks&amp;quot; that check for 127.0.0.1 or localhost? Have any filters to try and prevent GETs on certain actions? Relying on server variables passed in to your actions would make those scenarios (and many others) unwise. Just say no.&lt;/p&gt;
  735.  
  736. &lt;p&gt;In my opinion this feature (the server variable portion) should just be removed from the MVC framework entirely or something should be put in place to prevent overwriting parameters named the same as a server variable. &lt;/p&gt;
  737. </content>
  738. </entry>
  739. <entry>
  740.   <title>MVC Membership - Preview 3</title>
  741.   <link href="http://www.squaredroot.com/2008/07/02/mvc-membership-preview-3/"/>
  742.   <updated>2008-07-02T00:00:00+00:00</updated>
  743.   <id>http://www.squaredroot.com/2008/07/02/mvc-membership-preview-3</id>
  744.   <content type="html">&lt;p&gt;Tonight we posted a &lt;a href=&quot;http://www.codeplex.com/MvcMembership/Release/ProjectReleases.aspx?ReleaseId=14919&quot;&gt;new release of the MVC Membership Starter Kit&lt;/a&gt;. This release is an update to migrate the starter kit to &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx&quot;&gt;the new Preview 3 release of the MVC framework&lt;/a&gt;. While several bugs have been squashed, no major new functionality has been added.&lt;/p&gt;
  745.  
  746. &lt;p&gt;If you couldn&amp;#39;t wait and downloaded the source prior to the official Preview 3 release, you&amp;#39;ll still want to download tonight&amp;#39;s official release as several important issues have been addressed.&lt;/p&gt;
  747.  
  748. &lt;h2&gt;Bug Fixes in 1.3:&lt;/h2&gt;
  749.  
  750. &lt;ul&gt;
  751. &lt;li&gt;The System.Web.Abstraction, System.Web.Mvc, and System.Web.Routing DLLs being used prior to tonight were from an earlier Preview 3 release and were not signed by Microsoft.&lt;/li&gt;
  752. &lt;li&gt;Routing ambiguities caused a 404 error to occur when a user enters an incorrect username/password combination on the login page.&lt;/li&gt;
  753. &lt;li&gt;Several errors were occurring on various password recovery screens which created a bad user experience.&lt;/li&gt;
  754. &lt;li&gt;Errors on the administration section&amp;#39;s Create User and Display User pages were preventing that functionality from working at all.&lt;/li&gt;
  755. &lt;/ul&gt;
  756.  
  757. &lt;p&gt;Thanks for all of the interest everyone has shown in this project and thanks to &lt;a href=&quot;http://blog.maartenballiauw.be/&quot;&gt;Maarten&lt;/a&gt; and &lt;a href=&quot;http://gregorybeamer.spaces.live.com/blog/&quot;&gt;Greg&lt;/a&gt; for their contributions; especially to Maarten as he did most of the grunt work in upgrading our code base to Preview 3. Please send any feedback you have our way, we&amp;#39;d love to hear it!&lt;/p&gt;
  758. </content>
  759. </entry>
  760. <entry>
  761.   <title>SSL Links/URLs in MVC</title>
  762.   <link href="http://www.squaredroot.com/2008/06/11/mvc-and-ssl/"/>
  763.   <updated>2008-06-11T00:00:00+00:00</updated>
  764.   <id>http://www.squaredroot.com/2008/06/11/mvc-and-ssl</id>
  765.   <content type="html">&lt;p&gt;A couple days ago a reader sent me a question regarding how to use SSL with the MVC framework. Specifically the reader wanted to know the easiest way to make an Ajax call to a HTTPS page from a non HTTPS page. The tricky part here is to do so without hard-coding any URLs (as one of the best practices of the MVC framework is that views and controllers should be divorced from the routes that access them).&lt;/p&gt;
  766.  
  767. &lt;p&gt;Currently an ActionLink like:&lt;/p&gt;
  768.  
  769. &lt;script src=&quot;https://gist.github.com/4005985.js?file=Example-1.aspx&quot;&gt; &lt;/script&gt;
  770.  
  771. &lt;p&gt;... outputs the following hyperlink:&lt;/p&gt;
  772.  
  773. &lt;script src=&quot;https://gist.github.com/4005985.js?file=Example-2.html&quot;&gt; &lt;/script&gt;
  774.  
  775. &lt;p&gt;I&amp;#39;ve created a few extension methods that enable you to fully-qualify these URLs and change the protocol to HTTPS at run-time. Using the extension method &amp;quot;ToSslLink&amp;quot; like so:&lt;/p&gt;
  776.  
  777. &lt;script src=&quot;https://gist.github.com/4005985.js?file=Example-3.aspx&quot;&gt; &lt;/script&gt;
  778.  
  779. &lt;p&gt;... now outputs a hyperlink with protocol, server, port, etc:&lt;/p&gt;
  780.  
  781. &lt;script src=&quot;https://gist.github.com/4005985.js?file=Example-4.html&quot;&gt; &lt;/script&gt;
  782.  
  783. &lt;p&gt;If you&amp;#39;re using Ajax, however, you&amp;#39;ll be more interested in getting to the URL directly rather than building an entire hyperlink. In that case you can use &amp;quot;ToSslUrl&amp;quot;:&lt;/p&gt;
  784.  
  785. &lt;script src=&quot;https://gist.github.com/4005985.js?file=Example-5.aspx&quot;&gt; &lt;/script&gt;
  786.  
  787. &lt;p&gt;... to output this:&lt;/p&gt;
  788.  
  789. &lt;script src=&quot;https://gist.github.com/4005985.js?file=Example-6.txt&quot;&gt; &lt;/script&gt;
  790.  
  791. &lt;p&gt;Here is the code for the extension methods I&amp;#39;ve created, hopefully some of you will find this useful:&lt;/p&gt;
  792.  
  793. &lt;script src=&quot;https://gist.github.com/4005985.js?file=Example-7.cs&quot;&gt; &lt;/script&gt;
  794.  
  795. &lt;p&gt;One important missing element from all is this posting to a form via HTTPS from a non-HTTPS page. You can certainly create your form tags manually and populate the action attribute using Url.Action(...).ToSslUrl(), but you cannot try and combine these extension methods with the Html.Form(...) helper that is most commonly used inside a using statement.&lt;/p&gt;
  796.  
  797. &lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The above code was updated on July 7th, 2008 to fix a bug reported by &lt;a href=&quot;http://mikehadlow.blogspot.com&quot;&gt;Mike Hadlow&lt;/a&gt;. Thanks Mike!&lt;/p&gt;
  798. </content>
  799. </entry>
  800. <entry>
  801.   <title>Help Decide Sandcastle's Fate</title>
  802.   <link href="http://www.squaredroot.com/2008/06/10/sandcastle-removed-from-codeplex/"/>
  803.   <updated>2008-06-10T00:00:00+00:00</updated>
  804.   <id>http://www.squaredroot.com/2008/06/10/sandcastle-removed-from-codeplex</id>
  805.   <content type="html">&lt;p&gt;&lt;a href=&quot;http://articles.techrepublic.com.com/5100-10878_11-6174811.html&quot;&gt;Sandcastle&lt;/a&gt; - the .Net community equivalent of &lt;a href=&quot;http://rdoc.sourceforge.net/&quot;&gt;RDoc&lt;/a&gt;/&lt;a href=&quot;http://java.sun.com/j2se/javadoc/&quot;&gt;JavaDoc&lt;/a&gt; and the spiritual successor of the now defunct &lt;a href=&quot;http://ndoc.sourceforge.net/&quot;&gt;NDoc&lt;/a&gt; &amp;ndash; &lt;a href=&quot;http://blogs.msdn.com/sandcastle/archive/2008/06/06/sandcastle-project-removed-from-codeplex.aspx&quot;&gt;has been removed from CodePlex&lt;/a&gt;. It&amp;#39;s fate is currently up in the air and Microsoft is asking you for input on what should happen next. It was pulled down after the community at-large expressed reservations about Sandcastle being hosted on &lt;a href=&quot;http://www.codeplex.com&quot;&gt;CodePlex&lt;/a&gt; while not being published under an Open Source license or even being posted in source form at all. According to the announcement on MSDN, the possible future for Sandcastle involves two scenarios: &lt;/p&gt;
  806.  
  807. &lt;ul&gt;
  808. &lt;li&gt;Publish the source code for Sandcastle and revive this project in Codeplex&lt;/li&gt;
  809. &lt;li&gt;Migrate sandcastle to MSDN Code gallery at &lt;a href=&quot;http://code.msdn.microsoft.com/&quot;&gt;http://code.msdn.microsoft.com&lt;/a&gt;&lt;/li&gt;
  810. &lt;/ul&gt;
  811.  
  812. &lt;p&gt;I for one would love to see Sandcastle released as an open source project on CodePlex. It seems to me that Microsoft has had a great deal of success lately with releasing the MVC Framework as an open source project and I hope that they continue the trend. If you have used Sandcastle or foresee the need to have automatic code documentation generation on a project in the future, please do not hesitate to &lt;a href=&quot;http://blogs.msdn.com/sandcastle/archive/2008/06/06/sandcastle-project-removed-from-codeplex.aspx&quot;&gt;leave a comment&lt;/a&gt; letting the powers that be know how you feel. &lt;/p&gt;
  813. </content>
  814. </entry>
  815. <entry>
  816.   <title>We're Back</title>
  817.   <link href="http://www.squaredroot.com/2008/06/08/back-from-honeymoon/"/>
  818.   <updated>2008-06-08T00:00:00+00:00</updated>
  819.   <id>http://www.squaredroot.com/2008/06/08/back-from-honeymoon</id>
  820.   <content type="html">&lt;p&gt;After two weeks in gorgeous St. Lucia on honeymoon at the &lt;a href=&quot;http://www.sandals.com/main/grande/gl-home.cfm&quot;&gt;Sandals Grande St. Lucian&lt;/a&gt;, my new bride and I have returned to DC. Take a look at a few of the pictures we snapped along the way.&lt;/p&gt;
  821.  
  822. &lt;h2&gt;A Few Pictures&lt;/h2&gt;
  823.  
  824. &lt;p&gt;&lt;img src=&quot;/custom/files/old/HeadedToStLucia_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  825.  
  826. &lt;p&gt;After a hectic weekend, we got our first chance to relax at National Airport, waiting to depart for Miami and then on to St. Lucia.&lt;/p&gt;
  827.  
  828. &lt;p&gt;&lt;img src=&quot;/custom/files/old/OurHomeInStLucia_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  829.  
  830. &lt;p&gt;The backyard of our home away from home. To the right you can see our private pool (with the waterfall in the background). Not pictured: our outdoor shower &amp;amp; hot tub, plus a hammock that proved perfect for reading and relaxing. All this and only a stone&amp;#39;s throw from the beach!&lt;/p&gt;
  831.  
  832. &lt;p&gt;&lt;img src=&quot;/custom/files/old/AtDinner_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  833.  
  834. &lt;p&gt;Our butler scheduled an intimate dinner for the two of us at Gordon&amp;#39;s, a restaurant at the end of a pier only a few minutes walk from home. If you&amp;#39;ve never stayed at an all-inclusive, I highly recommend it. It was nice to eat at fine restaurants every night and just get up and leave without worrying about any bill.&lt;/p&gt;
  835.  
  836. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Hobie_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  837.  
  838. &lt;p&gt;First order of business the first morning in St. Lucia? Sailing. Lots of sailing. My hopes of sailing every day were not to be (so much else to do!), but I did manage to go out every other day or so.&lt;/p&gt;
  839.  
  840. &lt;p&gt;&lt;img src=&quot;/custom/files/old/SwimUpBar_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  841.  
  842. &lt;p&gt;We heart swim-up bars.&lt;/p&gt;
  843.  
  844. &lt;p&gt;&lt;img src=&quot;/custom/files/old/ThePitons_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  845.  
  846. &lt;p&gt;St. Lucia&amp;#39;s most famous landmarks, the Pitons, in the background. Also the namesake of St. Lucia&amp;#39;s most popular beer (which tastes remarkably like Corona).&lt;/p&gt;
  847.  
  848. &lt;p&gt;&lt;img src=&quot;/custom/files/old/ForestBridge_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  849.  
  850. &lt;p&gt;A tour guide led us into the outer fringes of the rainforest, where we wanted to swim in a waterfall.&lt;/p&gt;
  851.  
  852. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Waterfall_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  853.  
  854. &lt;p&gt;Which we did.&lt;/p&gt;
  855.  
  856. &lt;p&gt;&lt;img src=&quot;/custom/files/old/BackOfBoat_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  857.  
  858. &lt;p&gt;There was a lot of boating in St. Lucia. This was taken on a wild, wet ride back from the Pitons.&lt;/p&gt;
  859.  
  860. &lt;p&gt;&lt;img src=&quot;/custom/files/old/PoolRaft_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  861.  
  862. &lt;p&gt;We spent considerably more time in the humongous beach-side pool than on the beach proper. Lesson learned? The ocean needs more swim-up bars.&lt;/p&gt;
  863.  
  864. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Windsurfing_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  865.  
  866. &lt;p&gt;Windsurfing is hard. Hard, hard.&lt;/p&gt;
  867.  
  868. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Horseback_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  869.  
  870. &lt;p&gt;Riding horses bare-back in the surf is fun, but it also gave me a very healthy respect for the invention of saddles.&lt;/p&gt;
  871.  
  872. &lt;p&gt;&lt;img src=&quot;/custom/files/old/FrontOfCatamaran_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  873.  
  874. &lt;p&gt;Taken on the bow of a 50+ foot catamaran, which I&amp;#39;m trying to figure out how to add to my Amazon wish-list.&lt;/p&gt;
  875.  
  876. &lt;p&gt;&lt;img src=&quot;/custom/files/old/ByTheFountain_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  877.  
  878. &lt;p&gt;Uh oh, the trip is almost over, hurry up and take some nice photos!&lt;/p&gt;
  879.  
  880. &lt;p&gt;&lt;img src=&quot;/custom/files/old/AgainstATree_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  881.  
  882. &lt;p&gt;Who are these tan people, and what have they done with the folks from the first picture?&lt;/p&gt;
  883.  
  884. &lt;p&gt;&lt;img src=&quot;/custom/files/old/InTheBungalow_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  885.  
  886. &lt;p&gt;With picture time over, it&amp;#39;s time to relax in a beach-front bungalow until the sun goes down. Afterward it is off to pack and bid St. Lucia farewell in the morning.&lt;/p&gt;
  887.  
  888. &lt;p&gt;This is only a small selection of our wonderful two weeks. If anyone else is considering a trip with their significant other to the Caribbean, we cannot recommend St. Lucia highly enough and &lt;a href=&quot;http://www.sandals.com/main/grande/gl-home.cfm&quot;&gt;Sandals Grande St. Lucian&lt;/a&gt; was a wonderful place to stay.&lt;/p&gt;
  889. </content>
  890. </entry>
  891. <entry>
  892.   <title>Honeymoon Bound!</title>
  893.   <link href="http://www.squaredroot.com/2008/05/20/honeymoon-bound/"/>
  894.   <updated>2008-05-20T00:00:00+00:00</updated>
  895.   <id>http://www.squaredroot.com/2008/05/20/honeymoon-bound</id>
  896.   <content type="html">&lt;p&gt;I know, I know... I haven&amp;#39;t been blogging much recently, but don&amp;#39;t think that you&amp;#39;ve gotten rid of me yet. My fianc&amp;egrave; and I have been very busy preparing for our wedding, which after nearly a year of planning is now only days away [obligatory Office paraphrase: Mr. Troy Goode... Has a nice ring to it, don&amp;#39;t you think?]. On Monday Alexandra and I will be leaving for the &lt;a href=&quot;http://www.sandals.com/main/grande/gl-home.cfm&quot;&gt;Sandals Grande St. Lucian&lt;/a&gt; for two weeks of sun, sailing, and relaxing. There are still a couple things in the cooker that I&amp;#39;ll be working on after I get back, so hopefully you&amp;#39;ll be hearing more about that toward the end of June. Wish me luck! &lt;/p&gt;
  897.  
  898. &lt;h2&gt;Visual Studio / ReSharper Settings&lt;/h2&gt;
  899.  
  900. &lt;p&gt;I&amp;#39;ve been meaning to post my Visual Studio &amp;amp; ReSharper settings for a while, primarily so I have one central place to download the settings from when I set up a new machine at home or work. Feel free to ignore the files I&amp;#39;ve posted below, or try them out to see my modified dark color scheme! &lt;/p&gt;
  901.  
  902. &lt;p&gt;&lt;a href=&quot;/custom/files/old/VS2008.vssettings&quot;&gt;VS2008.vssettings&lt;/a&gt;
  903. &lt;a href=&quot;/custom/files/old/Resharper4Settings.xml&quot;&gt;Resharper4Settings.xml&lt;/a&gt;&lt;/p&gt;
  904. </content>
  905. </entry>
  906. <entry>
  907.   <title>MVC Membership Starter Kit - 1.2</title>
  908.   <link href="http://www.squaredroot.com/2008/04/28/mvc-membership-starter-kit-1-2/"/>
  909.   <updated>2008-04-28T00:00:00+00:00</updated>
  910.   <id>http://www.squaredroot.com/2008/04/28/mvc-membership-starter-kit-1-2</id>
  911.   <content type="html">&lt;p&gt;This weekend I posted a &lt;a href=&quot;https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=MvcMembership&amp;amp;ReleaseId=12667&quot;&gt;new release of the MVC Membership Starter Kit&lt;/a&gt;. This release is an update to migrate the starter kit to &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2008/04/16/asp-net-mvc-source-refresh-preview.aspx&quot;&gt;the new interim release of the MVC framework&lt;/a&gt;. If you do not feel comfortable using the interim release, please continue using the 1.1 release and wait for Microsoft to release Preview 3; we will update the Starter Kit soon thereafter.&lt;/p&gt;
  912.  
  913. &lt;h2&gt;Changes in 1.2:&lt;/h2&gt;
  914.  
  915. &lt;ul&gt;
  916. &lt;li&gt;WindowsLive is now a supported authentication scenario (&lt;a href=&quot;http://blog.maartenballiauw.be/post/2008/04/ASPNet-MVC-Membership-Starter-Kit-alternative-authentication.aspx&quot;&gt;read Maarten&amp;#39;s blog post on this&lt;/a&gt;).&lt;/li&gt;
  917. &lt;li&gt;Per &lt;a href=&quot;http://blog.nerdbank.net/&quot;&gt;Andrew Arnott&amp;#39;s&lt;/a&gt; suggestion, the starter kit now uses the &lt;a href=&quot;http://code.google.com/p/dotnetopenid/&quot;&gt;DotNetOpenId&lt;/a&gt; library rather than the code previously used (which was created by Mads Kristensen). This gives us a more robust and secure implementation that will develop and improve independently of this project.&lt;/li&gt;
  918. &lt;li&gt;All actions that previously expected a username in the route now expect the user&amp;#39;s ProviderUserKey (a Guid) instead. This was done because users with OpenID urls as their username could not previously be accessed.&lt;/li&gt;
  919. &lt;li&gt;&amp;quot;Whitelist support&amp;quot; has been added to the OpenID implementation, allowing you to setup regular expressions that dictate which OpenID providers are allowed to be used when logging into your site. By default there is no whitelist, so all providers are allowed.&lt;/li&gt;
  920. &lt;li&gt;The starter kit now offers greater control over which authentication scenarios your site supports and which is the default. Out-of-the-box only FormsAuthentication is enabled and is obviously the default.&lt;/li&gt;
  921. &lt;/ul&gt;
  922. </content>
  923. </entry>
  924. <entry>
  925.   <title>Massive BlogEngine.net Security Hole</title>
  926.   <link href="http://www.squaredroot.com/2008/04/13/massive-blogenginedotnet-security-hole/"/>
  927.   <updated>2008-04-13T00:00:00+00:00</updated>
  928.   <id>http://www.squaredroot.com/2008/04/13/massive-blogenginedotnet-security-hole</id>
  929.   <content type="html">&lt;p&gt;A massive security hole in BlogEngine.net was just revealed that allows anyone to see your passwords... Danny Douglass just added a post to his blog where he explains the issue and provides a patched BlogEngine.Core assembly to resolve the issue until the next release of BlogEngine is available.&lt;/p&gt;
  930.  
  931. &lt;p&gt;I would advise anyone running BlogEngine.net to immediately &lt;a href=&quot;http://dannydouglass.com/post/2008/04/BlogEngine-and-the-JavaScript-HttpHandler-Serious-Security-Issue.aspx&quot;&gt;go to Danny&amp;#39;s blog and download &amp;amp; install the fix&lt;/a&gt;.&lt;/p&gt;
  932.  
  933. &lt;p&gt;The faster we can get word out about this, the faster we can shut down this particular attack vector, so please try and get the word out to any BlogEngine.net users you are aware of and please &lt;a href=&quot;http://www.dotnetkicks.com/security/Massive_BlogEngine_Net_Security_Hole_Fix_Provided&quot;&gt;kick Danny&amp;#39;s post at DotNetKicks&lt;/a&gt;.&lt;/p&gt;
  934.  
  935. &lt;p&gt;Thanks Danny!&lt;/p&gt;
  936. </content>
  937. </entry>
  938. <entry>
  939.   <title>OpenID Check_Authentication In C#</title>
  940.   <link href="http://www.squaredroot.com/2008/04/11/openid-check_authentication/"/>
  941.   <updated>2008-04-11T00:00:00+00:00</updated>
  942.   <id>http://www.squaredroot.com/2008/04/11/openid-check_authentication</id>
  943.   <content type="html">&lt;p&gt;Earlier this year Mads Krisensen (of &lt;a href=&quot;http://www.dotnetblogengine.net/&quot;&gt;BlogEngine.net&lt;/a&gt; fame) posted a &lt;a href=&quot;http://blog.madskristensen.dk/post/OpenID-implementation-in-Csharp-and-ASPNET.aspx&quot;&gt;lightweight implementation of OpenID&lt;/a&gt; using C#. In the comments on Mads&amp;#39; post, &lt;a href=&quot;http://blog.nerdbank.net/&quot;&gt;Andrew Arnott&lt;/a&gt; (&lt;a href=&quot;http://blog.nerdbank.net/2008/04/dotnetopenid-2.html&quot;&gt;a developer of the DotNetOpenId library&lt;/a&gt;) mentioned that the example Mads had posted could &amp;quot;be hacked with a single change of a word in the URL.&amp;quot; This is what is technically referred to as a &lt;strong&gt;Very Bad Thing&lt;/strong&gt;. Andrew and another poster named &amp;quot;neil&amp;quot; went on to elaborate that implementing OpenID&amp;#39;s &amp;quot;check&lt;em&gt;authentication&amp;quot; algorithm would close this security hole. Unfortunately as of the writing of this article neither Mads nor any of the commentors have provided an implementation of check&lt;/em&gt;authentication that works with the class Mads posted (bear in mind that Andrew only brought up this issue less than a week ago, so Mads may very well be working on it).&lt;/p&gt;
  944.  
  945. &lt;p&gt;Fast forward to yesterday when I was researching my options for implementing OpenID for the next release of the &lt;a href=&quot;http://www.codeplex.com/MvcMembership&quot;&gt;ASP.Net MVC Membership Starter Kit&lt;/a&gt;. I liked Mads solution more than the other OpenID libraries that are current available because of its brevity and how easy it is to include it in a project without introducing an extra assembly dependency, so I decided to go ahead and add the check_authentication functionality. A quick read of &lt;a href=&quot;http://openid.net/specs/openid-authentication-1_1.html#mode_check_authentication&quot;&gt;that portion of the OpenID spec&lt;/a&gt; and a couple hours of coding/testing and I think I&amp;#39;m about finished.&lt;/p&gt;
  946.  
  947. &lt;p&gt;Here is the method you need to add to Mads&amp;#39; class:&lt;/p&gt;
  948.  
  949. &lt;script src=&quot;https://gist.github.com/4006111.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  950.  
  951. &lt;p&gt;Now you need to make sure that method is called from somewhere. I chose to make the method private and just call it from inside the Authenticate method. Within the Authenticate method replace:&lt;/p&gt;
  952.  
  953. &lt;script src=&quot;https://gist.github.com/4006111.js?file=Example-2.cs&quot;&gt; &lt;/script&gt;
  954.  
  955. &lt;p&gt;... with...&lt;/p&gt;
  956.  
  957. &lt;script src=&quot;https://gist.github.com/4006111.js?file=Example-3.cs&quot;&gt; &lt;/script&gt;
  958.  
  959. &lt;p&gt;And that&amp;#39;s it!&lt;/p&gt;
  960.  
  961. &lt;p&gt;If anyone with more experience than I in OpenID waters sees a problem with my implementation, let me know and I will try to get it fixed quickly.&lt;/p&gt;
  962.  
  963. &lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; I am aware that Mads&amp;#39; implementation and the use of &amp;#39;check_authentication&amp;#39; is considered an overly chatty use of OpenID. It seems to me that the extra complexity required to implement OpenID 2.0 protocol is just not worthwhile for most OpenID consumers. Feel free to let me know why this is a stupid position to take.&lt;/p&gt;
  964. </content>
  965. </entry>
  966. <entry>
  967.   <title>MVC: New Membership Starter Kit Release</title>
  968.   <link href="http://www.squaredroot.com/2008/04/11/mvc-membership-starter-kit-11/"/>
  969.   <updated>2008-04-11T00:00:00+00:00</updated>
  970.   <id>http://www.squaredroot.com/2008/04/11/mvc-membership-starter-kit-11</id>
  971.   <content type="html">&lt;h2&gt;The Starter Kit&lt;/h2&gt;
  972.  
  973. &lt;p&gt;If you haven&amp;#39;t had a chance to read about the MVC Membership Starter Kit I&amp;#39;ve created, &lt;a href=&quot;/2008/04/02/mvc-membership-starter-kit/&quot;&gt;read this post first&lt;/a&gt;.&lt;/p&gt;
  974.  
  975. &lt;h2&gt;New Release&lt;/h2&gt;
  976.  
  977. &lt;p&gt;Since we first created the starter kit a week and a half ago, &lt;a href=&quot;http://blog.maartenballiauw.be/&quot;&gt;Maarten Balliauw&lt;/a&gt; and I have been hard at work fleshing out the implementation to provide as much functionality as possible. Last night we finished the last stretch of things we had identified for this release and have posted the code as a new release on CodePlex. Keep in mind you can also always download our latest builds from CodePlex as well without waiting for a new release.&lt;/p&gt;
  978.  
  979. &lt;h2&gt;New Features&lt;/h2&gt;
  980.  
  981. &lt;h3&gt;OpenID&lt;/h3&gt;
  982.  
  983. &lt;p&gt;Mads Kristensen &lt;a href=&quot;http://blog.madskristensen.dk/post/OpenID-implementation-in-Csharp-and-ASPNET.aspx&quot;&gt;released a lightweight OpenID consumer&lt;/a&gt; earlier this year that I then proceeded to flesh out with &lt;a href=&quot;/2008/04/11/openid-check_authentication/&quot;&gt;a security patch&lt;/a&gt;. The reason I did so was so that I could include OpenID in this release of the Starter Kit.&lt;/p&gt;
  984.  
  985. &lt;p&gt;Out of the box you can create a route to the OpenIDLogin action, which displays the following view:&lt;/p&gt;
  986.  
  987. &lt;p&gt;&lt;img src=&quot;/custom/files/old/OpenID_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  988.  
  989. &lt;p&gt;Once the user has entered their OpenID url, the starter kit will take care of the rest for you, with one critical exception: you have to map the url to a user in your membership database. To do so, you simple override a virtual method and return a MembershipUser, like so:&lt;/p&gt;
  990.  
  991. &lt;script src=&quot;https://gist.github.com/4006125.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  992.  
  993. &lt;p&gt;Note that the above implementation maps the OpenID url to a user&amp;#39;s UserName, which may or may not be what you want for your application. Adjust accordingly.&lt;/p&gt;
  994.  
  995. &lt;h3&gt;Password Recovery Tools&lt;/h3&gt;
  996.  
  997. &lt;p&gt;Maarten did a great job providing users with a way to manage their passwords. While logged in they can change their password:&lt;/p&gt;
  998.  
  999. &lt;p&gt;&lt;img src=&quot;/custom/files/old/ChangePassword_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1000.  
  1001. &lt;p&gt;Or if they are having trouble logging in, they can submit their username...&lt;/p&gt;
  1002.  
  1003. &lt;p&gt;&lt;img src=&quot;/custom/files/old/ForgotPassword_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1004.  
  1005. &lt;p&gt;...and then answer their password question (if the system is configured to require it)...&lt;/p&gt;
  1006.  
  1007. &lt;p&gt;&lt;img src=&quot;/custom/files/old/PasswordQuestion_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1008.  
  1009. &lt;p&gt;...and they will then receive their password via email (or a newly generated password -- depending on system configuration).&lt;/p&gt;
  1010.  
  1011. &lt;h3&gt;Client-Side Validation&lt;/h3&gt;
  1012.  
  1013. &lt;p&gt;All non-administrative forms now include basic client-side validation. The validations even change based upon your Membership settings.&lt;/p&gt;
  1014.  
  1015. &lt;p&gt;For instance, by default the ASP.Net Membership provider requires passwords to contain at least 1 non-alphanumeric character. If a user entered a password of &amp;quot;password&amp;quot; they would see the following alert:&lt;/p&gt;
  1016.  
  1017. &lt;p&gt;&lt;img src=&quot;/custom/files/old/ClientSideValidation_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1018.  
  1019. &lt;h3&gt;Components: Login &amp;amp; LoginStatus&lt;/h3&gt;
  1020.  
  1021. &lt;p&gt;Maarten created components that emulate the functionality of the old Login and LoginStatus controls. Now it is easy to have a Login box on every page.&lt;/p&gt;
  1022.  
  1023. &lt;h3&gt;Major Refactoring&lt;/h3&gt;
  1024.  
  1025. &lt;p&gt;Most of the controller and filter code has been broken out into a separate assembly.&lt;/p&gt;
  1026.  
  1027. &lt;p&gt;Your FormsAuthentication and FormsAuthenticationAdministration controllers should now inherit from a base version of each. Maarten has created a boat load of virtual method hooks for each action (OnBeforeBlah, OnAfterBlah, OnErrorBlah) that provides you with easy extensibility points without needing to directly modify the starter kit base code.&lt;/p&gt;
  1028.  
  1029. &lt;p&gt;Hopefully this refactoring will make it easy for you to upgrade to future versions of the starter kit&amp;#39;s code as they become available.&lt;/p&gt;
  1030.  
  1031. &lt;h2&gt;The Future&lt;/h2&gt;
  1032.  
  1033. &lt;p&gt;Currently we&amp;#39;ve cleared our plate and have no more planned features to attend to. Does this mean that we are done? No. This is what you can expect to see us working on next:&lt;/p&gt;
  1034.  
  1035. &lt;ul&gt;
  1036. &lt;li&gt;Preview3 updates, whenever it becomes available.&lt;/li&gt;
  1037. &lt;li&gt;Validations on the administrative side.&lt;/li&gt;
  1038. &lt;li&gt;Bug fixes, of course. :-)&lt;/li&gt;
  1039. &lt;li&gt;If you have suggestions for what you would like to see in the next release, please &lt;a href=&quot;mailto:troygoode@gmail.com&quot;&gt;drop me an email&lt;/a&gt; and let me know!&lt;/li&gt;
  1040. &lt;/ul&gt;
  1041.  
  1042. &lt;p&gt;You can &lt;a href=&quot;https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=MvcMembership&amp;amp;ReleaseId=12261&quot;&gt;download the new release&lt;/a&gt; from CodePlex. &lt;/p&gt;
  1043. </content>
  1044. </entry>
  1045. <entry>
  1046.   <title>Rob Conery's PagedList Class (Updated)</title>
  1047.   <link href="http://www.squaredroot.com/2008/04/08/updated-pagedlist-class/"/>
  1048.   <updated>2008-04-08T00:00:00+00:00</updated>
  1049.   <id>http://www.squaredroot.com/2008/04/08/updated-pagedlist-class</id>
  1050.   <content type="html">&lt;p class=&quot;warning&quot;&gt;A new, improved version of this class is now available &lt;a href=&quot;/2011/06/28/pagedlist-can-haz-htmlhelperz/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
  1051.  
  1052. &lt;p&gt;Robert Muehsig has posted a great user control for the MVC framework that &lt;a href=&quot;http://code-inside.de/blog-in/2008/04/08/aspnet-mvc-pagination-view-user-control/&quot;&gt;adds pagination links to the bottom of a paged list&lt;/a&gt;. In it he used a slightly customized version of &lt;a href=&quot;http://blog.wekeroad.com/2007/12/10/aspnet-mvc-pagedlistt/&quot;&gt;Rob Conery&amp;#39;s PagedList&lt;/a&gt; class that Rob was kind enough to post way back when the first CTP was released. This reminded me that I should probably post the version I have customized, as I think it makes it a bit easier to use and maintain. Check out the code &lt;a href=&quot;https://github.com/troygoode/pagedlist&quot;&gt;on GitHub.&lt;/a&gt;&lt;/p&gt;
  1053.  
  1054. &lt;h2&gt;Changes from Rob&amp;#39;s version:&lt;/h2&gt;
  1055.  
  1056. &lt;ul&gt;
  1057. &lt;li&gt;&lt;strong&gt;Added a &amp;quot;TotalPages&amp;quot; property.&lt;/strong&gt; If you&amp;#39;re going to loop through each of the pages to display page navigation, you&amp;#39;ll obviously need this.&lt;/li&gt;
  1058. &lt;li&gt;&lt;strong&gt;Changed &amp;quot;IsPreviousPage&amp;quot; to &amp;quot;HasPreviousPage&amp;quot;.&lt;/strong&gt; It just sounds better.&lt;/li&gt;
  1059. &lt;li&gt;&lt;strong&gt;Changed &amp;quot;IsNextPage&amp;quot; to &amp;quot;HasNextPage&amp;quot;.&lt;/strong&gt; See above.&lt;/li&gt;
  1060. &lt;li&gt;&lt;strong&gt;Added a &amp;quot;IsFirstPage&amp;quot; property.&lt;/strong&gt; The opposite way of using the above two properties. I prefer this way, but kept the original way for backwards compatibility (except the naming).&lt;/li&gt;
  1061. &lt;li&gt;&lt;strong&gt;Added a &amp;quot;IsLastPage&amp;quot; property.&lt;/strong&gt; See above.&lt;/li&gt;
  1062. &lt;li&gt;&lt;strong&gt;Changed the first constructor to accept IEnumerable&amp;lt;T&amp;gt; rather than IQueryable&amp;lt;T&amp;gt;.&lt;/strong&gt; I&amp;#39;m not exactly sure why Rob originally made it IQueryable. I&amp;#39;m aware that by passing an IQueryable (LINQ) object to this constructor you&amp;#39;ll avoid retrieving the entire set (only taking the results needed), but since IQueryable inherits from IEnumerable everything should be hunky-dory. He probably had a reason and I&amp;#39;m going to wind up breaking all of my stuff, but IEnumerable is just so much handier. =)&lt;/li&gt;
  1063. &lt;li&gt;&lt;strong&gt;Removed the second constructor.&lt;/strong&gt; The second constructor took List&amp;lt;T&amp;gt;, which is unnecessary after changing the first constructor to accept IEnumerable.&lt;/li&gt;
  1064. &lt;li&gt;&lt;strong&gt;Cleaned up property declarations a bit.&lt;/strong&gt; Mainly to make the page a bit shorter, but also to prevent the multiple calculations that could happen in the original. Also the original allowed the changing of certain properties after an instance was created, which would put the instance into an inconsistent state.&lt;/li&gt;
  1065. &lt;li&gt;&lt;strong&gt;Added argument checking and handled a few exception scenarios more gracefully.&lt;/strong&gt; Trying to make debugging a bit friendlier. &lt;/li&gt;&lt;/li&gt;
  1066. &lt;li&gt;&lt;strong&gt;Removed the second extension method that didn&amp;#39;t specify a pageSize.&lt;/strong&gt; I don&amp;#39;t really think that baking in an extension method that sets pageSize to 10 is a good idea, I&amp;#39;d prefer pageSize to be explicitly set elsewhere by the calling code.&lt;/li&gt;
  1067. &lt;li&gt;&lt;strong&gt;Moved the code to the &amp;quot;System.Collections.Generic&amp;quot; namespace.&lt;/strong&gt; I&amp;#39;m sure a lot of you are breaking out in a cold sweat to see me putting something into a System.* namespace, but I kind of feel like this is something that the .Net team just &amp;quot;forgot&amp;quot;. =) Move it wherever makes you comfortable.&lt;/li&gt;
  1068. &lt;/ul&gt;
  1069.  
  1070. &lt;p&gt;Please note that I took many of these ideas from the commentary below Rob&amp;#39;s original post. I&amp;#39;m sure many of you are using something similar, but I thought it would be useful to get something posted online that is a bit more fleshed out than the original example.&lt;/p&gt;
  1071.  
  1072. &lt;p&gt;Thanks for the great work Rob &amp;amp; Robert!&lt;/p&gt;
  1073. </content>
  1074. </entry>
  1075. <entry>
  1076.   <title>Review: Training With Stephen Walther</title>
  1077.   <link href="http://www.squaredroot.com/2008/04/04/training-with-stephen-walther/"/>
  1078.   <updated>2008-04-04T00:00:00+00:00</updated>
  1079.   <id>http://www.squaredroot.com/2008/04/04/training-with-stephen-walther</id>
  1080.   <content type="html">&lt;p&gt;I just finished a four day course on AJAX, LINQ, &amp;amp; MVC taught by &lt;a href=&quot;http://www.superexpert.com/&quot;&gt;Stephen Walther&lt;/a&gt; and wanted to let all of you know that if you are interested in training on any of these topics, I HIGHLY recommend Stephen.&lt;/p&gt;
  1081.  
  1082. &lt;p&gt;You can learn more about the training options he offers by visiting his training website:
  1083. &lt;a href=&quot;http://www.superexperttraining.com/&quot;&gt;http://www.superexperttraining.com/&lt;/a&gt;&lt;/p&gt;
  1084.  
  1085. &lt;p&gt;He also keeps a blog filled with incredibly information -- and long ;-) -- posts on various aspects of ASP.Net at:
  1086. &lt;a href=&quot;http://weblogs.asp.net/StephenWalther/&quot;&gt;http://weblogs.asp.net/StephenWalther/&lt;/a&gt;&lt;/p&gt;
  1087.  
  1088. &lt;p&gt;Read on for more details about my experiences this week.&lt;/p&gt;
  1089.  
  1090. &lt;h2&gt;The Instructor&lt;/h2&gt;
  1091.  
  1092. &lt;p&gt;Stephen is a successful author, having literally &amp;quot;written the book&amp;quot; on ASP.Net (and even ASP Classic!). His book &amp;quot;ASP.NET 3.5 Unleashed&amp;quot; has received excellent reviews from Amazon and I look forward to reading it soon.&lt;/p&gt;
  1093.  
  1094. &lt;p&gt;You can buy Stephen&amp;#39;s book from Amazon here:&lt;/p&gt;
  1095.  
  1096. &lt;p&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/0672330113&quot;&gt;&lt;img src=&quot;/custom/files/old/AspNet35UnleashedCover.jpeg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/a&gt;&lt;/p&gt;
  1097.  
  1098. &lt;p&gt;We all found Stephen to be very personable and he obviously has an excellent command on the language and tools available in the .Net ecosystem. Also, anyone that can put up with my constant interruptions and derails for four days in a windowless classroom is clearly a pro. =)&lt;/p&gt;
  1099.  
  1100. &lt;h2&gt;The Course&lt;/h2&gt;
  1101.  
  1102. &lt;p&gt;&lt;a href=&quot;http://www.dannydouglass.com/&quot;&gt;Danny Douglass&lt;/a&gt; originally contacted Stephen to request that he teach a class for seven of our developers at &lt;a href=&quot;http://www.nreca.coop/&quot;&gt;the organization we work for&lt;/a&gt;. Stephen was kind enough to then customize a course around the technologies we had requested, and that is how we ended up with a one day primer on LINQ &amp;amp; MVC followed by an in-depth training session on AJAX technologies and Microsoft&amp;#39;s ASP.Net AJAX implementation specifically.&lt;/p&gt;
  1103.  
  1104. &lt;p&gt;As anyone that reads my blog regularly knows, I am heavily invested in learning the MVC framework and was highly impressed by Stephens grasp on such a new technology. We may very well have been the first ASP.Net MVC class that anyone has taught anywhere and Stephen managed to teach it quickly and confidently. I was also impressed that he was teaching us things based upon the Preview 2 release of the MVC framework which has only been available publicly for 3 weeks rather than the older December CTP release.&lt;/p&gt;
  1105.  
  1106. &lt;p&gt;As someone that considers himself a strong JavaScript developer, I came into the class a little worried that the JavaScript explanation portions of the program would be more remedial than I wanted. I was wrong. Stephen led a thorough review over the advanced JavaScript features developers need to know to develop world-class AJAX libraries and did so while keeping the pace brisk and managing not to leave anyone in the room behind.&lt;/p&gt;
  1107.  
  1108. &lt;p&gt;As I said above, I recommend Stephen&amp;#39;s training courses to anyone organization interested in learning AJAX, JavaScript, MVC, LINQ, or ASP.Net in general. Thanks for the excellent class Stephen!&lt;/p&gt;
  1109.  
  1110. &lt;p&gt;&lt;strong&gt;Disclaimer: I was not paid or compensated in any way for this endorsement.&lt;/strong&gt;&lt;/p&gt;
  1111. </content>
  1112. </entry>
  1113. <entry>
  1114.   <title>MVC: Membership Starter Kit</title>
  1115.   <link href="http://www.squaredroot.com/2008/04/02/mvc-membership-starter-kit/"/>
  1116.   <updated>2008-04-02T00:00:00+00:00</updated>
  1117.   <id>http://www.squaredroot.com/2008/04/02/mvc-membership-starter-kit</id>
  1118.   <content type="html">&lt;p class=&quot;warning&quot;&gt;A newer version of the Membership Starter Kit is now available. &lt;a href=&quot;/2008/04/11/mvc-membership-starter-kit-11/&quot;&gt;Click here&lt;/a&gt; to see what has changed.&lt;/p&gt;
  1119.  
  1120. &lt;h2&gt;Introduction&lt;/h2&gt;
  1121.  
  1122. &lt;p&gt;One of my very first blog posts (and most definitely my most popular so far) revolved around &lt;a href=&quot;/2007/12/10/aspnet-mvc-membership-basics/&quot;&gt;how to integrate ASP.Net membership and forms authentication into the ASP.Net MVC framework&lt;/a&gt; which had just been released in it&amp;#39;s December CTP flavor. It has remained popular to this day, but unfortunately the Preview 2 release of the MVC framework has caused much of the code I released in that article to no longer function correctly.&lt;/p&gt;
  1123.  
  1124. &lt;p&gt;Even before the release of Preview 2, I had been planning to extend the samples I was providing to offer more useful features. I don&amp;#39;t know about you, but nearly every website I ever create with ASP.Net requires some kind of security/membership system. My preference is to use the built-in system when possible (except for the horrible Profiles sub-system). This means creating login, logout, &amp;amp; registration functionality every time, as well as creating administrative screens for managing the users that enter your system.&lt;/p&gt;
  1125.  
  1126. &lt;p&gt;WebForms provides some controls to help with the login and registration process, but user administration has always been delegated to either (a) the built-in tool that runs separately and doesn&amp;#39;t work remotely or (b) rolling your own solution. The development of the MVC framework seems to me like a good time to resolve this scenario and provide the community with an array of pre-built tools to help boot-strap projects so that we can stop working on infrastructure and start working on the heart of the individual application.&lt;/p&gt;
  1127.  
  1128. &lt;p&gt;&lt;strong&gt;With that in mind I have created a CodePlex project: the &lt;a href=&quot;http://www.codeplex.com/MvcMembership&quot;&gt;ASP.Net MVC Membership Starter Kit&lt;/a&gt;.&lt;/strong&gt; It currently provides controllers and views for all of the common authentication and user administration needs, including:&lt;/p&gt;
  1129.  
  1130. &lt;ul&gt;
  1131. &lt;li&gt;Login/Logout&lt;/li&gt;
  1132. &lt;li&gt;Registration&lt;/li&gt;
  1133. &lt;li&gt;List of Registered Users&lt;/li&gt;
  1134. &lt;li&gt;User Details / Administration&lt;/li&gt;
  1135. &lt;li&gt;Role Management&lt;/li&gt;
  1136. &lt;/ul&gt;
  1137.  
  1138. &lt;p&gt;A big thanks goes out to Rob Conery, as I borrowed his recent &lt;a href=&quot;http://blog.wekeroad.com/blog/aspnet-mvc-securing-your-controller-actions/&quot;&gt;Authentication Filters&lt;/a&gt; and included those, along with my recently released &lt;a href=&quot;/2008/04/02/mvc-error-handler-filter/&quot;&gt;Error Handling Filters&lt;/a&gt;.&lt;/p&gt;
  1139.  
  1140. &lt;p&gt;Okay, enough wall o&amp;#39;text. Let&amp;#39;s take a look at some screenshots:&lt;/p&gt;
  1141.  
  1142. &lt;h2&gt;Screenshot Tour&lt;/h2&gt;
  1143.  
  1144. &lt;p&gt;Here is the menu when you first log in:&lt;/p&gt;
  1145.  
  1146. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Menu-LoggedOut_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1147.  
  1148. &lt;p&gt;The registration page:&lt;/p&gt;
  1149.  
  1150. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Registration_4.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1151.  
  1152. &lt;p&gt;The login page (note that the Administrator&amp;#39;s credentials are displayed to make it easy to get started, you&amp;#39;ll obviously want to change them and remove that note):&lt;/p&gt;
  1153.  
  1154. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Login_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1155.  
  1156. &lt;p&gt;Having logged in, here is what the menu looks like now:&lt;/p&gt;
  1157.  
  1158. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Menu-LoggedIn_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1159.  
  1160. &lt;p&gt;The current options upon clicking the Security tab:&lt;/p&gt;
  1161.  
  1162. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Security_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1163.  
  1164. &lt;p&gt;Clicking &amp;quot;Manage Users&amp;quot; brings you to a list of all users currently registered:&lt;/p&gt;
  1165.  
  1166. &lt;p&gt;&lt;img src=&quot;/custom/files/old/ManageUsers_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1167.  
  1168. &lt;p&gt;Clicking on the user takes you to a form that allows you to view their details and edit a few aspects of their profile...&lt;/p&gt;
  1169.  
  1170. &lt;p&gt;&lt;img src=&quot;/custom/files/old/User-Top_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1171.  
  1172. &lt;p&gt;as well as view/change the roles they are in and help with password issues:&lt;/p&gt;
  1173.  
  1174. &lt;p&gt;&lt;img src=&quot;/custom/files/old/User-Bottom_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1175.  
  1176. &lt;p&gt;From the Security tab you can also go to a list of all the system&amp;#39;s roles, from which you can add/delete roles as you need:&lt;/p&gt;
  1177.  
  1178. &lt;p&gt;&lt;img src=&quot;/custom/files/old/Roles_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1179.  
  1180. &lt;p&gt;Clicking on a role from the roles list or the user profile allows you to view/modify the users in that role:&lt;/p&gt;
  1181.  
  1182. &lt;p&gt;&lt;img src=&quot;/custom/files/old/UsersInRole_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1183.  
  1184. &lt;p&gt;And finally, the Security tab offers a link to another registration form, geared toward Administrators:&lt;/p&gt;
  1185.  
  1186. &lt;p&gt;&lt;img src=&quot;/custom/files/old/CreateUser_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1187.  
  1188. &lt;h2&gt;NSFAQ (Not-So Frequently Asked Questions)&lt;/h2&gt;
  1189.  
  1190. &lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Does this compete with MvcContrib?&lt;br&gt;
  1191. &lt;strong&gt;A:&lt;/strong&gt; No. &lt;a href=&quot;http://www.codeplex.com/MVCContrib&quot;&gt;MvcContrib&lt;/a&gt; is a great project that aims to features like alternate routing and view engines, and IoC integration. This project is simply a starter kit to help get membership-based applications off the ground a little quicker. There is no reason you could not use both projects together.&lt;/p&gt;
  1192.  
  1193. &lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; What dependencies does using this starter kit saddle me with?&lt;br&gt;
  1194. &lt;strong&gt;A:&lt;/strong&gt; Ideally, none, other than the ASP.Net Membership API. Every measure will be taken to avoid using third party libraries, be it JavaScript or .Net. We will strive to separate the code and rely on default settings as much as possible to make it easy for you to customize your installation without anything in the starter kit getting in the way.&lt;/p&gt;
  1195.  
  1196. &lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Who is responsible for this?&lt;br&gt;
  1197. &lt;strong&gt;A:&lt;/strong&gt; Currently, only &lt;a href=&quot;https://github.com/troygoode&quot;&gt;me&lt;/a&gt;, but I&amp;#39;d like that to change! I&amp;#39;m keenly interested in finding a few other developers that would like to contribute to enhancing the starter kit. Please &lt;a href=&quot;mailto:troygoode@gmail.com&quot;&gt;email me&lt;/a&gt; if you&amp;#39;d like to help!&lt;/p&gt;
  1198.  
  1199. &lt;h2&gt;What&amp;#39;s Next?&lt;/h2&gt;
  1200.  
  1201. &lt;p&gt;There are a few features missing that I would like to include in the very short term. Primarily these are features for end-users, like Change Password and Forgot My Password (both of which are currently available on the administration side). Beyond that, visual cleanup of the forms (and separation of the style sheets) as well as a bit of AJAX-ification of the forms would be nice. If you use the starter kit and have suggestions or criticisms, please post to the &lt;a href=&quot;http://www.codeplex.com/MvcMembership/Thread/List.aspx&quot;&gt;Discussions forum&lt;/a&gt; or &lt;a href=&quot;http://www.codeplex.com/MvcMembership/WorkItem/List.aspx&quot;&gt;Issue Tracker&lt;/a&gt;!&lt;/p&gt;
  1202.  
  1203. &lt;p&gt;You can download the latest release from &lt;a href=&quot;http://www.codeplex.com/MvcMembership&quot;&gt;the CodePlex project&lt;/a&gt;. I hope you all find it useful!&lt;/p&gt;
  1204. </content>
  1205. </entry>
  1206. <entry>
  1207.   <title>MVC: Action Filter for Handling Errors</title>
  1208.   <link href="http://www.squaredroot.com/2008/04/02/mvc-error-handler-filter/"/>
  1209.   <updated>2008-04-02T00:00:00+00:00</updated>
  1210.   <id>http://www.squaredroot.com/2008/04/02/mvc-error-handler-filter</id>
  1211.   <content type="html">&lt;p&gt;A few months ago I posted &lt;a href=&quot;/2008/01/04/mvc-authentication-and-errors/&quot;&gt;an article and some code&lt;/a&gt; that contained filters for forms authentication and error handling for the Preview 1 (CTP) release of the MVC framework. Unfortunately &lt;a href=&quot;http://blogs.msdn.com/brada/archive/2008/03/05/asp-net-mvc-preview-2.aspx&quot;&gt;the Preview 2 release&lt;/a&gt; that was made available a few weeks ago changed enough that the code I posted no longer works. &lt;/p&gt;
  1212.  
  1213. &lt;p&gt;What the Preview 2 release did provide, however, was a new built-in filter framework. Rob Conery has already gone through the trouble of &lt;a href=&quot;http://blog.wekeroad.com/blog/aspnet-mvc-securing-your-controller-actions/&quot;&gt;creating authentication filters&lt;/a&gt; that cover most of the functionality I had before, but I have yet to see an implementation of a filter for error handling that I like. I&amp;#39;ve gone ahead and started from scratch, throwing away my old filters, and created a new filter that I think covers most of the same scenarios as my old ErrorHandler filters while being much simpler to implement and use. Hopefully you&amp;#39;ll find it useful. &lt;/p&gt;
  1214.  
  1215. &lt;p&gt;First let&amp;#39;s take a look at a simple use case scenario: &lt;/p&gt;
  1216.  
  1217. &lt;script src=&quot;https://gist.github.com/4006173.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  1218.  
  1219. &lt;p&gt;In the code above, we have a simple action that displays a product based upon the ID specified. What do we do when no ID is specified though? The &amp;quot;correct&amp;quot; thing to do seems to be to throw an exception, as we&amp;#39;ve done, but now the user will see either (a) an ugly 500 error screen [worst case] or (b) be redirected to the generic error page [best case]. Sometimes we&amp;#39;d like a bit more control than that though... &lt;/p&gt;
  1220.  
  1221. &lt;p&gt;Let&amp;#39;s go ahead and add our error handling filter to this action and tell it that whenever &lt;strong&gt;ArgumentNullException&lt;/strong&gt; is thrown, redirect to the &amp;quot;Products&amp;quot; page, where the user can select a product with a valid ID. &lt;/p&gt;
  1222.  
  1223. &lt;script src=&quot;https://gist.github.com/4006173.js?file=Example-2.cs&quot;&gt; &lt;/script&gt;
  1224.  
  1225. &lt;p&gt;So we&amp;#39;ve added a [&lt;strong&gt;RedirectToUrlOnError&lt;/strong&gt;] attribute and supplied it with a &lt;strong&gt;Type&lt;/strong&gt; property - detailing the exception to catch - and a &lt;strong&gt;Url&lt;/strong&gt; property - specifying the &lt;strong&gt;Url&lt;/strong&gt; to navigate to upon a matched exception. You&amp;#39;ll notice we are making a call to the &lt;strong&gt;GetProduct&lt;/strong&gt;(&lt;em&gt;int&lt;/em&gt;) method to retrieve the product&amp;#39;s model so that we can pass it into the view&amp;#39;s ViewData. What if this method were to fail? What if we weren&amp;#39;t entirely certain what exception it would throw, or maybe we didn&amp;#39;t care, we just want to handle any exception except for &lt;strong&gt;ArgumentNullException&lt;/strong&gt; (which is already being handled). In this case we&amp;#39;ll add another filter, but this time we will not specify the &lt;strong&gt;Type&lt;/strong&gt; of exception that it should catch and just tell it that if anything isn&amp;#39;t caught by another error handler redirect to the homepage. &lt;/p&gt;
  1226.  
  1227. &lt;script src=&quot;https://gist.github.com/4006173.js?file=Example-3.cs&quot;&gt; &lt;/script&gt;
  1228.  
  1229. &lt;p&gt;You can have as many error handler filters attached to an action as you need, but only one may have no Type specified. &lt;/p&gt;
  1230.  
  1231. &lt;p&gt;Now let&amp;#39;s take a look at the code for the filter itself:&lt;/p&gt;
  1232.  
  1233. &lt;script src=&quot;https://gist.github.com/4006173.js?file=Example-4.cs&quot;&gt; &lt;/script&gt;
  1234.  
  1235. &lt;p&gt;So the [&lt;strong&gt;RedirectToUrlOnError&lt;/strong&gt;] attribute inherits from the [&lt;strong&gt;RedirectOnError&lt;/strong&gt;] attribute, which is where most of the hard work is done. We&amp;#39;ll take a look at that base class in a bit, but first let&amp;#39;s look at the other attribute you can use to trap and respond to errors - the [&lt;strong&gt;RedirectToActionOnError&lt;/strong&gt;] attribute. We&amp;#39;ll continue with the &lt;strong&gt;Product&lt;/strong&gt;(&lt;em&gt;id&lt;/em&gt;) sample from above, but this time redirect to an action rather than a hardcoded Url:&lt;/p&gt;
  1236.  
  1237. &lt;script src=&quot;https://gist.github.com/4006173.js?file=Example-5.cs&quot;&gt; &lt;/script&gt;
  1238.  
  1239. &lt;p&gt;You can see that this time instead of providing the Url property we are using providing the type of the controller that contains our target action, and the name of the action as a string. (Unfortunately lambda expressions are not allowed as parameters to an attribute, so I was limited in my options here. If you have a better idea, please let me know!) Also note that the catch-all is still there as a [&lt;strong&gt;RedirectToUrlOnError&lt;/strong&gt;] attribute. You may use the [&lt;strong&gt;RedirectToActionOnError&lt;/strong&gt;] attribute as a catch-all and you can mix and match the two attribute types, but still only one catch-all attribute total is allowed per action (in other words, you cannot have one of each).&lt;/p&gt;
  1240.  
  1241. &lt;p&gt;Now let&amp;#39;s see the code for this filter:&lt;/p&gt;
  1242.  
  1243. &lt;script src=&quot;https://gist.github.com/4006173.js?file=Example-6.cs&quot;&gt; &lt;/script&gt;
  1244.  
  1245. &lt;p&gt;Other than some complexity with determining the Url, everything is very similar to the other filter. Again it appears the base class is doing the heavy lifting. Let&amp;#39;s finally take a look at that base class:&lt;/p&gt;
  1246.  
  1247. &lt;script src=&quot;https://gist.github.com/4006173.js?file=Example-7.cs&quot;&gt; &lt;/script&gt;
  1248.  
  1249. &lt;p&gt;That&amp;#39;s all there is. Feel free to take it, use it, change it, whatever. I tried my best to document it thoroughly with comments, but if you have any questions just drop a comment below and I&amp;#39;ll try to respond quickly. I do ask that if you make any improvements, please leave a comment here letting everyone know what you&amp;#39;ve changed so that we can all benefit. &lt;/p&gt;
  1250.  
  1251. &lt;h2&gt;Here are the filters in a downloadable format:&lt;/h2&gt;
  1252.  
  1253. &lt;p&gt;&lt;a href=&quot;/custom/files/old/RedirectOnErrorAttributes.zip&quot;&gt;RedirectOnErrorAttributes.zip&lt;/a&gt;&lt;/p&gt;
  1254. </content>
  1255. </entry>
  1256. <entry>
  1257.   <title>MVC: How Do I RedirectToAction While Passing a Parameter?</title>
  1258.   <link href="http://www.squaredroot.com/2008/04/01/redirecttoaction-with-parameter/"/>
  1259.   <updated>2008-04-01T00:00:00+00:00</updated>
  1260.   <id>http://www.squaredroot.com/2008/04/01/redirecttoaction-with-parameter</id>
  1261.   <content type="html">&lt;p&gt;A common scenario that seems under-documented to me in the latest MVC release, is how does one use RedirectToAction while passing a value to that action?&lt;/p&gt;
  1262.  
  1263. &lt;p&gt;In the December CTP, you would do this:&lt;/p&gt;
  1264.  
  1265. &lt;script src=&quot;https://gist.github.com/4006179.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  1266.  
  1267. &lt;p&gt;The new syntax is close, but not easily discoverable. Instead of the above, from now on you should use:&lt;/p&gt;
  1268.  
  1269. &lt;script src=&quot;https://gist.github.com/4006179.js?file=Example-2.cs&quot;&gt; &lt;/script&gt;
  1270. </content>
  1271. </entry>
  1272. <entry>
  1273.   <title>MVC: How Do I Prevent Exposing a Public Method on a Controller?</title>
  1274.   <link href="http://www.squaredroot.com/2008/03/31/nonaction-on-controller/"/>
  1275.   <updated>2008-03-31T00:00:00+00:00</updated>
  1276.   <id>http://www.squaredroot.com/2008/03/31/nonaction-on-controller</id>
  1277.   <content type="html">&lt;p&gt;The purists will say that you shouldn&amp;#39;t have any public methods on a controller that aren&amp;#39;t meant to be exposed via a view or redirect to another action. Assuming that you, like I, have encountered a situation where you need/want to do this, however, here is what you do:&lt;/p&gt;
  1278.  
  1279. &lt;script src=&quot;https://gist.github.com/4006183.js&quot;&gt; &lt;/script&gt;
  1280.  
  1281. &lt;p&gt;The &lt;strong&gt;System.Web.Mvc.NonAction&lt;/strong&gt; attribute will prevent your public method from being accessed via any routes.&lt;/p&gt;
  1282. </content>
  1283. </entry>
  1284. <entry>
  1285.   <title>Lambdas Using Funcs and Actions</title>
  1286.   <link href="http://www.squaredroot.com/2008/02/12/lambdas-using-funcs-and-actions/"/>
  1287.   <updated>2008-02-12T00:00:00+00:00</updated>
  1288.   <id>http://www.squaredroot.com/2008/02/12/lambdas-using-funcs-and-actions</id>
  1289.   <content type="html">&lt;p&gt;Many of you are probably familiar with &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2007/04/08/new-orcas-language-feature-lambda-expressions.aspx&quot;&gt;lambda expressions&lt;/a&gt; by now, as they have been extensively covered since the release of .Net 3.5. Most articles tend to focus on how to pass a lambda expression into a method, but how do you create a method that accepts a lambda expression? Enter the &lt;strong&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/bb549151.aspx&quot;&gt;Func&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/system.action.aspx&quot;&gt;Action&lt;/a&gt;&lt;/strong&gt; types...&lt;/p&gt;
  1290.  
  1291. &lt;h2&gt;Funcs vs. Actions&lt;/h2&gt;
  1292.  
  1293. &lt;p&gt;&lt;strong&gt;Funcs&lt;/strong&gt; and &lt;strong&gt;Actions&lt;/strong&gt; are extremely similar; both give you first class support for passing an anonymous method into another method. The difference is in the return value: &lt;strong&gt;Funcs&lt;/strong&gt; have one, &lt;strong&gt;Actions&lt;/strong&gt; do not.&lt;/p&gt;
  1294.  
  1295. &lt;h2&gt;A Simple Action Consumer&lt;/h2&gt;
  1296.  
  1297. &lt;p&gt;There are several variants of the &lt;strong&gt;Action&lt;/strong&gt; type, each taking a varying number of generic parameters. The simplest generic &lt;strong&gt;Action&lt;/strong&gt; takes one generic parameters: the type of the object to be passed into the &lt;strong&gt;Action&lt;/strong&gt;.&lt;/p&gt;
  1298.  
  1299. &lt;p&gt;Suppose you had a list of articles and wanted to iterate through them and modify each of them in some way, but only the ones that were created before 2008. In this case you should probably use a &lt;strong&gt;foreach&lt;/strong&gt; loop, but instead I&amp;#39;ll show you how to do it by encapsulating that &lt;strong&gt;foreach&lt;/strong&gt; loop in another method that then calls your lambda:&lt;/p&gt;
  1300.  
  1301. &lt;script src=&quot;https://gist.github.com/4006198.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  1302.  
  1303. &lt;p&gt;I&amp;#39;ll be the first to admit it isn&amp;#39;t the finest example of coding practices, but I believe it illustrates how you can use an &lt;strong&gt;Action&lt;/strong&gt; to pass processing in as a parameter.&lt;/p&gt;
  1304.  
  1305. &lt;h2&gt;A Simple Func Consumer&lt;/h2&gt;
  1306.  
  1307. &lt;p&gt;What if you want to pass in your processing and retrieve a return value? Use the &lt;strong&gt;Func&lt;/strong&gt; type. Let&amp;#39;s keep the same example as above, but this time we&amp;#39;ll place variable processing in the lambda to manipulate the article&amp;#39;s title differently based upon the year the article was published:&lt;/p&gt;
  1308.  
  1309. &lt;script src=&quot;https://gist.github.com/4006198.js?file=Example-2.cs&quot;&gt; &lt;/script&gt;
  1310.  
  1311. &lt;p&gt;In the above example you&amp;#39;ll see that we have changed &lt;strong&gt;Action&lt;/strong&gt; to &lt;strong&gt;Func&lt;/strong&gt; in the &lt;strong&gt;IterateArticles&lt;/strong&gt; method signature and that we have added a string to the list of types in the &lt;strong&gt;Func&lt;/strong&gt; definition. &lt;em&gt;When using a *&lt;/em&gt;Func*&lt;em&gt;, the last generic parameter is always the return type.&lt;/em&gt; You should also note that we can now return a value from our anonymous method.&lt;/p&gt;
  1312.  
  1313. &lt;h2&gt;A Two-Parameter Func&lt;/h2&gt;
  1314.  
  1315. &lt;p&gt;Finally let&amp;#39;s take a look at an example of a multi-parameter &lt;strong&gt;Func&lt;/strong&gt;. Once again we&amp;#39;ll use the same example, except this time rather than passing the &lt;strong&gt;Article&lt;/strong&gt; object to the anonymous method we&amp;#39;ll pass only the data it needs: the date created and the title:&lt;/p&gt;
  1316.  
  1317. &lt;script src=&quot;https://gist.github.com/4006198.js?file=Example-3.cs&quot;&gt; &lt;/script&gt;
  1318.  
  1319. &lt;p&gt;Here we have specified three generic parameters for the &lt;strong&gt;Func&lt;/strong&gt;; two to be passed in, one to return. In our lambda expression we have also had to wrap the &amp;quot;x,y&amp;quot; in parentheses to prevent the compiler from throwing an error because it thinks the comma is intended to separate parameters to the &lt;strong&gt;IterateArticles&lt;/strong&gt; method rather than the &lt;strong&gt;Func.&lt;/strong&gt;&lt;/p&gt;
  1320.  
  1321. &lt;h2&gt;A Zero-Parameter Func&lt;/h2&gt;
  1322.  
  1323. &lt;p&gt;Occasionally you may need to use a &lt;strong&gt;Func&lt;/strong&gt; that will not require any parameters. Trying to pass this into the lambda consumer using only the &amp;quot;{...}&amp;quot; notation of anonymous methods will not work, you will need to use &amp;quot;()=&amp;gt;{...}&amp;quot; as seen below:&lt;/p&gt;
  1324.  
  1325. &lt;script src=&quot;https://gist.github.com/4006198.js?file=Example-4.cs&quot;&gt; &lt;/script&gt;
  1326.  
  1327. &lt;p&gt;I hope this helps get you started creating your own lambda consuming methods. Keep in mind that &lt;strong&gt;Funcs&lt;/strong&gt; and &lt;strong&gt;Actions&lt;/strong&gt; are not limited to just one or two parameters as shown in this article; both can accept up to four input parameters (not including the &lt;strong&gt;Func&amp;#39;s&lt;/strong&gt; extra return parameter). As you become more comfortable creating lambda expressions and lambda consumers I am certain you will find many places in our your code that can be simplified and/or made more flexible by using them. &lt;/p&gt;
  1328. </content>
  1329. </entry>
  1330. <entry>
  1331.   <title>Storing LINQ Objects in SQL-Based Session State</title>
  1332.   <link href="http://www.squaredroot.com/2008/01/30/storing-linq-objects-in-sql-based-session-state/"/>
  1333.   <updated>2008-01-30T00:00:00+00:00</updated>
  1334.   <id>http://www.squaredroot.com/2008/01/30/storing-linq-objects-in-sql-based-session-state</id>
  1335.   <content type="html">&lt;p&gt;Scott Hanselman &lt;a href=&quot;http://www.hanselman.com/blog/TroubleshootingExpiredASPNETSessionStateAndYourOptions.aspx&quot;&gt;recently posted about various options you have for session storage&lt;/a&gt; while using ASP.Net. In the comments of his post I brought up an issue I recently encountered at work (where we use SQL Server session state):&lt;/p&gt;
  1336.  
  1337. &lt;p&gt;&lt;strong&gt;LINQ-To-Sql generated objects are not marked [Serializable] and cannot be stored in out-of-process session storage.&lt;/strong&gt;&lt;/p&gt;
  1338.  
  1339. &lt;p&gt;To get around this I have whipped up the following helper class which will serialize LINQ-To-Sql objects if you set the DataContext&amp;#39;s Serializable property to &amp;quot;Unidirectional&amp;quot;.&lt;/p&gt;
  1340.  
  1341. &lt;p&gt;&lt;strong&gt;Note: The following class does not current work for storing List&amp;lt;X&amp;gt; where X is a LINQ-To-Sql object. I&amp;#39;ll be working to resolve that sometime later this week.&lt;/strong&gt;&lt;/p&gt;
  1342.  
  1343. &lt;script src=&quot;https://gist.github.com/4006217.js&quot;&gt; &lt;/script&gt;
  1344. </content>
  1345. </entry>
  1346. <entry>
  1347.   <title>MVC: Strongly Typed ViewData Without A Code-Behind</title>
  1348.   <link href="http://www.squaredroot.com/2008/01/07/mvc-strongly-type-viewpages-without-a-code-behind/"/>
  1349.   <updated>2008-01-07T00:00:00+00:00</updated>
  1350.   <id>http://www.squaredroot.com/2008/01/07/mvc-strongly-type-viewpages-without-a-code-behind</id>
  1351.   <content type="html">&lt;p&gt;If you&amp;#39;ve tried to use strongly-typed &lt;strong&gt;ViewData&lt;/strong&gt; with a &lt;strong&gt;ViewPage&lt;/strong&gt; or &lt;strong&gt;ViewContentPage&lt;/strong&gt; without using a code-behind file you may have run into the curious scenario of how to specify a generic in the &lt;strong&gt;&amp;lt;%@ Page %&amp;gt;&lt;/strong&gt; element&amp;#39;s &lt;strong&gt;Inherits&lt;/strong&gt; attribute.&lt;/p&gt;
  1352.  
  1353. &lt;h2&gt;The Problem&lt;/h2&gt;
  1354.  
  1355. &lt;p&gt;Let&amp;#39;s say you wanted to specify that the &lt;strong&gt;ViewData&lt;/strong&gt; for this view would be an integer. Normally you would specify this in the code-behind like so:&lt;/p&gt;
  1356.  
  1357. &lt;script src=&quot;https://gist.github.com/4007445.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  1358.  
  1359. &lt;p&gt;Since we don&amp;#39;t have a code-behind file though, we have to change the &lt;em&gt;.aspx&lt;/em&gt; file&amp;#39;s &lt;strong&gt;&amp;lt;%@ Page %&amp;gt;&lt;/strong&gt; element. Trying to set it to the following will not work:&lt;/p&gt;
  1360.  
  1361. &lt;script src=&quot;https://gist.github.com/4007445.js?file=Example-2.aspx&quot;&gt; &lt;/script&gt;
  1362.  
  1363. &lt;h2&gt;The Basic Answer&lt;/h2&gt;
  1364.  
  1365. &lt;p&gt;The value of the &lt;strong&gt;Inherits&lt;/strong&gt; attribute appears to be delivered straight to the CLR without any language specific parsing, which means we have to specify it the way the CLR wants to interpret it. I browsed around and found (&lt;a href=&quot;http://forums.asp.net/t/1193721.aspx&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=104071&amp;amp;wa=wsignin1.0&quot;&gt;here&lt;/a&gt;) some information that points out the proper way to do this:&lt;/p&gt;
  1366.  
  1367. &lt;script src=&quot;https://gist.github.com/4007445.js?file=Example-3.aspx&quot;&gt; &lt;/script&gt;
  1368.  
  1369. &lt;h2&gt;WTF?&lt;/h2&gt;
  1370.  
  1371. &lt;p&gt;Eww, huh? The syntax is gnarly, but it gets the job done. Let&amp;#39;s break the syntax down to make sure you understand what is going on:&lt;/p&gt;
  1372. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;ParentType`1[ [ChildType,ChildTypeAssembly] ]
  1373. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  1374. &lt;ul&gt;
  1375. &lt;li&gt;&lt;em&gt;&amp;quot;ParentType&amp;quot;&lt;/em&gt; is fairly obvious. This is the generic object that you want to create a reference to.&lt;/li&gt;
  1376. &lt;li&gt;&lt;em&gt;&amp;quot;&amp;#x60;1[ [&amp;quot;&lt;/em&gt; is a bit more obscure. The &amp;quot;&amp;#x60;1&amp;quot; specifies the number of generics in this argument, which we&amp;#39;ll come back to in a second. The double square brackets are required. A single square bracket will &lt;strong&gt;NOT&lt;/strong&gt; work.&lt;/li&gt;
  1377. &lt;li&gt;&lt;em&gt;&amp;quot;ChildType&amp;quot;&lt;/em&gt; is the type of object you wish to have the generic consume (what is the proper terminology here? anyone know?).&lt;/li&gt;
  1378. &lt;li&gt;&lt;em&gt;&amp;quot;ChildTypeAssembly&amp;quot;&lt;/em&gt; is the name of the assembly (&lt;strong&gt;NOT&lt;/strong&gt; the namespace) that contains the &lt;em&gt;ChildType&lt;/em&gt;. All of your common value types will be located in &amp;quot;&lt;strong&gt;mscorlib&lt;/strong&gt;&amp;quot;.&lt;/li&gt;
  1379. &lt;/ul&gt;
  1380.  
  1381. &lt;h2&gt;Multiple Generic Types&lt;/h2&gt;
  1382.  
  1383. &lt;p&gt;Let&amp;#39;s say &lt;strong&gt;ViewPage&lt;/strong&gt; took two arguments as part of its generic declaration area (ie: &lt;strong&gt;ViewPage&amp;lt;X,Y&amp;gt;&lt;/strong&gt;). It doesn&amp;#39;t, by the way, but we&amp;#39;ll pretend it does for the sake of argument; you may find this information useful someday.&lt;/p&gt;
  1384.  
  1385. &lt;p&gt;To have two type parameters, you&amp;#39;ll have to change the &amp;quot;&amp;#x60;1&amp;quot; to a &amp;quot;&amp;#x60;2&amp;quot; and add an extra &lt;strong&gt;&amp;quot;[ChildType, ChildTypeAssembly]&amp;quot;&lt;/strong&gt; reference, separated by a space. More parameters would continue to follow the same logic.&lt;/p&gt;
  1386.  
  1387. &lt;p&gt;If you wanted to achieve the equivalent of &lt;strong&gt;ViewPage&amp;lt;int,string&amp;gt;&lt;/strong&gt; it would look like this:&lt;/p&gt;
  1388. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;System.Web.Mvc.ViewPage`2[ [System.Int32,mscorlib], [System.String,mscorlib] ]
  1389. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  1390. &lt;h2&gt;A Generic of Generics&lt;/h2&gt;
  1391.  
  1392. &lt;p&gt;A more likely scenario is that you may want to have your &lt;strong&gt;ViewData&lt;/strong&gt; be a generic &lt;strong&gt;List&amp;lt;T&amp;gt;&lt;/strong&gt;. In this case you&amp;#39;ll just nest the declarations. If you wanted to pass &lt;strong&gt;ViewData&lt;/strong&gt; of the type &lt;strong&gt;List&amp;lt;string&amp;gt;&lt;/strong&gt; to the &lt;strong&gt;ViewPage&lt;/strong&gt; it would look like:&lt;/p&gt;
  1393. &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;System.Web.Mvc.ViewPage`1[[System.Collections.Generic.List`1[[System.String,mscorlib]], mscorlib]]
  1394. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content>
  1395. </entry>
  1396. <entry>
  1397.   <title>BlogEngine Extension: Copy Code to Clipboard</title>
  1398.   <link href="http://www.squaredroot.com/2008/01/07/copy-code-to-clipboard-extension-for-blogengine/"/>
  1399.   <updated>2008-01-07T00:00:00+00:00</updated>
  1400.   <id>http://www.squaredroot.com/2008/01/07/copy-code-to-clipboard-extension-for-blogengine</id>
  1401.   <content type="html">&lt;p&gt;Since I first started this blog I&amp;#39;ve been using Colin Coller&amp;#39;s &lt;a href=&quot;http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/&quot;&gt;CopySourceAsHtml plugin&lt;/a&gt; for Visual Studio (which &lt;a href=&quot;http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/11/21/copy-source-as-html-copysourceashtml-for-visual-studio-2008-rtm.aspx&quot;&gt;Guy Burstein updated&lt;/a&gt; for Visual Studio 2008&amp;#39;s RTM). It was a nice little tool but as I started posting more and more code snippets to the blog I found myself wanting some additional features, specifically: &lt;/p&gt;
  1402.  
  1403. &lt;ul&gt;
  1404. &lt;li&gt;&lt;strong&gt;Easy to use&lt;/strong&gt;. While it was perfectly simple to copy the source as html, it was a bit more cumbersome to paste it properly into &lt;a href=&quot;http://get.live.com/writer/overview&quot;&gt;Windows Live Writer&lt;/a&gt;. I wound up in HTML mode in WLW everytime I needed to paste some code.&lt;/li&gt;
  1405. &lt;li&gt;&lt;strong&gt;CSS support&lt;/strong&gt;. The Html generated by the VS plugin inlines all of the styles and makes it difficult to change the presentation of your code without tweaking the settings of the plugin at posting time.&lt;/li&gt;
  1406. &lt;li&gt;&lt;strong&gt;Scrollable&lt;/strong&gt;. This is mostly handled by the above feature, but I wanted to be able to limit the amount of screen real estate taken up by the code while still allowing my readers to view more of the code without having to download any files.&lt;/li&gt;
  1407. &lt;li&gt;&lt;strong&gt;Copyable&lt;/strong&gt;. Sometimes you see a piece of code that fits your situation perfectly, but when you copy it you wind up with a bunch of extra Html guck and line numbers at the front of every line you have to manually remove. I want to allow my readers to copy the code without any of that mess.&lt;/li&gt;
  1408. &lt;/ul&gt;
  1409.  
  1410. &lt;p&gt;I found &lt;a href=&quot;http://code.google.com/p/syntaxhighlighter/&quot;&gt;syntaxhighlighter&lt;/a&gt; on Google Code pretty quickly and was impressed. I&amp;#39;d seen it around on other people&amp;#39;s blogs and loved the &amp;quot;copy to clipboard&amp;quot; feature, but I really wanted a server-side (or pre-posting) highlighter that would take some of the strain off the browser and wanted something with richer WLW integration. &lt;/p&gt;
  1411.  
  1412. &lt;p&gt;After looking at a few more options I finally found &lt;a href=&quot;http://lvildosola.blogspot.com/2007/02/code-snippet-plugin-for-windows-live.html&quot;&gt;Leo Vildosola&amp;#39;s Code Snippet&lt;/a&gt; plugin, which matched up with all of my requirements except for the lack of a built-in &amp;quot;copy to clipboard&amp;quot; feature. With some help from &lt;a href=&quot;http://webchicanery.com/2006/11/14/clipboard-copy-javascript/&quot;&gt;clipboard copying javascript posted at WebChicanery&lt;/a&gt; I set out to build an extension for &lt;a href=&quot;http://www.dotnetblogengine.net/&quot;&gt;BlogEngine.net&lt;/a&gt; that would automatically tack on the copy feature to any code I posted via the Code Snippet plugin. &lt;/p&gt;
  1413.  
  1414. &lt;p&gt;A few hours later, I present the CopyCodeToClipboard extension for BlogEngine.net! Below you will find an example of the extension displaying it&amp;#39;s own code (mmm... dogfood) and the css I&amp;#39;ve used to style the code on my site. I&amp;#39;ve tried to make the extension css friendly so you can change it&amp;#39;s presentation a great deal without modifying the code. &lt;/p&gt;
  1415.  
  1416. &lt;p&gt;&lt;a href=&quot;/custom/files/old/CopyCodeToClipboard.zip&quot;&gt;CopyCodeToClipboard.zip&lt;/a&gt;&lt;/p&gt;
  1417.  
  1418. &lt;p&gt;Contains all of the below files in one convenient package. &lt;/p&gt;
  1419.  
  1420. &lt;p&gt;&lt;hr&gt;&lt;/p&gt;
  1421.  
  1422. &lt;p&gt;&lt;a href=&quot;/custom/files/old/CopyCodeToClipboard.cs&quot;&gt;CopyCodeToClipboard.cs&lt;/a&gt;&lt;/p&gt;
  1423.  
  1424. &lt;p&gt;This is the actual extension and should be placed into your root/App_Code/Extensions/ folder.&lt;/p&gt;
  1425.  
  1426. &lt;script src=&quot;https://gist.github.com/4007483.js?file=CopyCodeToClipboard.cs&quot;&gt; &lt;/script&gt;
  1427.  
  1428. &lt;p&gt;&lt;hr&gt;&lt;/p&gt;
  1429.  
  1430. &lt;p&gt;&lt;a href=&quot;/custom/files/old/WLWSyntaxHighlighter.css&quot;&gt;WLWSyntaxHighlighter.css&lt;/a&gt;&lt;/p&gt;
  1431.  
  1432. &lt;p&gt;The Css generated by the Windows Live Writer Code Snippet plugin, modified to fit into my blog&amp;#39;s colors. &lt;/p&gt;
  1433.  
  1434. &lt;script src=&quot;https://gist.github.com/4007483.js?file=WLWSyntaxHighlighter.css&quot;&gt; &lt;/script&gt;
  1435.  
  1436. &lt;p&gt;&lt;hr&gt;&lt;/p&gt;
  1437.  
  1438. &lt;p&gt;&lt;a href=&quot;/custom/files/old/CopyCodeToClipboard.css&quot;&gt;CopyCodeToClipboard.css&lt;/a&gt;&lt;/p&gt;
  1439.  
  1440. &lt;p&gt;The Css I use to style the little red tab below each code area. This is what you would change to match your blog. &lt;/p&gt;
  1441.  
  1442. &lt;script src=&quot;https://gist.github.com/4007483.js?file=CopyToClipboard.css&quot;&gt; &lt;/script&gt;
  1443.  
  1444. &lt;p&gt;&lt;hr&gt;&lt;/p&gt;
  1445.  
  1446. &lt;p&gt;&lt;a href=&quot;/custom/files/old/clipboard.swf&quot;&gt;clipboard.swf&lt;/a&gt;&lt;/p&gt;
  1447.  
  1448. &lt;p&gt;A Macromedia Flash file used to circumvent Firefox &amp;amp; Safari&amp;#39;s nasty habit of blocking javascript from interacting with the clipboard. Created (as best I can tell) by Mark O&amp;#39;Sullivan of &lt;a href=&quot;http://lussumo.com/%22%20title=%22http://lussumo.com/&quot;&gt;http://lussumo.com/&lt;/a&gt;. &lt;/p&gt;
  1449.  
  1450. &lt;p&gt;&lt;hr&gt;&lt;/p&gt;
  1451.  
  1452. &lt;p&gt;&lt;strong&gt;Update (July 11, 2008):&lt;/strong&gt;&lt;/p&gt;
  1453.  
  1454. &lt;p&gt;A release of the Code Snippet plug hasn&amp;#39;t been made since the last changes to its source was checked in (in late 2007), so I went ahead and downloaded &amp;amp; built the source. To install the plug place the two DLLs in the zip file from below into Windows Live Writer&amp;#39;s /Plugins/ directory.&lt;/p&gt;
  1455.  
  1456. &lt;p&gt;&lt;a href=&quot;/custom/files/old/CodeSnippetPlugin.zip&quot;&gt;CodeSnippetPlugin.zip&lt;/a&gt;&lt;/p&gt;
  1457. </content>
  1458. </entry>
  1459. <entry>
  1460.   <title>MVC Authentication and Errors</title>
  1461.   <link href="http://www.squaredroot.com/2008/01/04/mvc-authentication-and-errors/"/>
  1462.   <updated>2008-01-04T00:00:00+00:00</updated>
  1463.   <id>http://www.squaredroot.com/2008/01/04/mvc-authentication-and-errors</id>
  1464.   <content type="html">&lt;p class=&quot;warning&quot;&gt;This article was written for the December CTP release of the MVC framework. Unfortunately, it does not entirely apply to the Preview 2 release or subsequent releases.&lt;/p&gt;
  1465.  
  1466. &lt;p&gt;I love working with the &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-3-5-extensions-ctp-preview-released.aspx&quot;&gt;recent CTP release&lt;/a&gt; of the ASP.Net MVC framework, but it is definitely an early release and is lacking many of the developer friendly features that we have grown to rely upon in WebForms. One such feature is WebForm&amp;#39;s easy to understand authentication model.&lt;/p&gt;
  1467.  
  1468. &lt;p&gt;In the WebForms world URLs can be referenced in a web.config file and then have authentication rules applied to them. A rule that says that you must be logged in to view a secure page may look something like:&lt;/p&gt;
  1469.  
  1470. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-1.xml&quot;&gt; &lt;/script&gt;
  1471.  
  1472. &lt;p&gt;A rule that says only users in the Administrators group may view it might look like this:&lt;/p&gt;
  1473.  
  1474. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-2.xml&quot;&gt; &lt;/script&gt;
  1475.  
  1476. &lt;p&gt;It didn&amp;#39;t take long for me to run into the lack of any central authentication scheme in the new MVC framework. I searched around and found some &lt;a href=&quot;http://weblogs.asp.net/fredriknormen/archive/2007/11/25/asp-net-mvc-framework-security.aspx&quot;&gt;older information from prior to the CTP release posted by Fredrik Normen&lt;/a&gt; that seemed to address my issues, but unfortunately one of the features his solution requires did not make its way into the CTP release: attribute based exception handling.&lt;/p&gt;
  1477.  
  1478. &lt;p&gt;Looking through the code samples on the page you see how he uses the .Net frameworks built in &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/system.security.permissions.principalpermission.aspx&quot;&gt;&lt;strong&gt;PrincipalPermission&lt;/strong&gt;&lt;/a&gt; attribute (from &lt;strong&gt;System.Security.Permissions&lt;/strong&gt;) to classify an action as demanding the user be in a specific role. If the user is not in that role the .Net framework will throw a &lt;strong&gt;SecurityException&lt;/strong&gt;. What good does that do? Well take a look at line 3 in the below code:&lt;/p&gt;
  1479.  
  1480. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-3.cs&quot;&gt; &lt;/script&gt;
  1481.  
  1482. &lt;p&gt;The &lt;strong&gt;ExceptionHandler&lt;/strong&gt; attribute appears to take two values:&lt;/p&gt;
  1483.  
  1484. &lt;ul&gt;
  1485. &lt;li&gt;The view to render in the event of an error.&lt;/li&gt;
  1486. &lt;li&gt;The type of error to match against.&lt;/li&gt;
  1487. &lt;/ul&gt;
  1488.  
  1489. &lt;p&gt;So based upon this code the &lt;strong&gt;PrincipalPermission&lt;/strong&gt; will interrogate the user&amp;#39;s roles when the action is requested and if the user is not in the &amp;quot;Admin&amp;quot; role it will throw a &lt;strong&gt;SecurityException&lt;/strong&gt;. At that point the &lt;strong&gt;ExceptionHandler&lt;/strong&gt; will wake up and say &amp;quot;hey I can handle that&amp;quot; and render the view named &amp;quot;Error&amp;quot;. Neat huh? Too bad &lt;strong&gt;ExceptionHandler&lt;/strong&gt; doesn&amp;#39;t exist...&lt;/p&gt;
  1490.  
  1491. &lt;p&gt;Personally I liked most of the concepts that were introduced in Frederik&amp;#39;s post, so I went ahead and began to implement the &lt;strong&gt;ExceptionHandler&lt;/strong&gt; attribute. Along the way I realized that what was really needed was a way to apply filters to a controller. I&amp;#39;ve seen &lt;a href=&quot;http://flanders.co.nz/blog/archive/2007/12/17/implementing-filters-in-asp.net-mvc.aspx&quot;&gt;Ivan Carrero&amp;#39;s controller filter implementation&lt;/a&gt;, but I wanted filters that hooked straight into the MVC Controller&amp;#39;s three major lifecycle events: &lt;strong&gt;OnPreAction&lt;/strong&gt;, &lt;strong&gt;OnPostAction&lt;/strong&gt;, and &lt;strong&gt;OnError&lt;/strong&gt;. By doing so I felt I would minimize the difference between code in a filter and code in a controller. Thus was born the &lt;strong&gt;FilterController&lt;/strong&gt;.&lt;/p&gt;
  1492.  
  1493. &lt;h2&gt;Filter Controller&lt;/h2&gt;
  1494.  
  1495. &lt;p&gt;The &lt;strong&gt;FilterController&lt;/strong&gt; is an abstract class deriving from the &lt;strong&gt;System.Web.Mvc.Controller&lt;/strong&gt;. It&amp;#39;s primary purpose is to interrogate itself via reflection when it is created and to then load any attributes that implement the &lt;strong&gt;IControllerFilter&lt;/strong&gt; interface:&lt;/p&gt;
  1496.  
  1497. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-4.cs&quot;&gt; &lt;/script&gt;
  1498.  
  1499. &lt;p&gt;The filters are then called for each of the three integration events: &lt;strong&gt;OnPreAction&lt;/strong&gt;, &lt;strong&gt;OnPostAction&lt;/strong&gt;, and &lt;strong&gt;OnError&lt;/strong&gt;. Here is what the &lt;strong&gt;OnError&lt;/strong&gt; event does:&lt;/p&gt;
  1500.  
  1501. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-5.cs&quot;&gt; &lt;/script&gt;
  1502.  
  1503. &lt;p&gt;The &lt;strong&gt;OnPreAction&lt;/strong&gt; and &lt;strong&gt;OnPostAction&lt;/strong&gt; events look almost exactly like the &lt;strong&gt;OnError&lt;/strong&gt; event.&lt;/p&gt;
  1504.  
  1505. &lt;p&gt;To fulfill my initial goal of obtaining functionality similar to that described in Frederik&amp;#39;s post, I have created two filters:&lt;/p&gt;
  1506.  
  1507. &lt;ul&gt;
  1508. &lt;li&gt;&lt;strong&gt;SecurityFilter&lt;/strong&gt;&lt;/li&gt;
  1509. &lt;li&gt;&lt;strong&gt;ErrorHandlerFilter&lt;/strong&gt;&lt;/li&gt;
  1510. &lt;/ul&gt;
  1511.  
  1512. &lt;h2&gt;Security Filter&lt;/h2&gt;
  1513.  
  1514. &lt;p&gt;While the &lt;strong&gt;PrincipalPermission&lt;/strong&gt; attribute used in Frederik&amp;#39;s post handles many security scenarios well, it wasn&amp;#39;t as flexible or keyboard friendly as I would prefer. I created the &lt;strong&gt;SecurityFilter&lt;/strong&gt; and an arrangement of sub-filters to create what I think is an easier solution.&lt;/p&gt;
  1515.  
  1516. &lt;p&gt;To use the security filter in your controller you must first inherit from &lt;strong&gt;FilterController&lt;/strong&gt; and apply the &lt;strong&gt;[SecurityFilter]&lt;/strong&gt; attribute.&lt;/p&gt;
  1517.  
  1518. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-6.cs&quot;&gt; &lt;/script&gt;
  1519.  
  1520. &lt;p&gt;This alone does nothing, but you are now able to add one or more of the &lt;strong&gt;SecurityFilter&lt;/strong&gt;&amp;#39;s sub-filters to this controller or it&amp;#39;s actions. The sub-filters I have created are:&lt;/p&gt;
  1521.  
  1522. &lt;ul&gt;
  1523. &lt;li&gt;&lt;strong&gt;RequireLogin&lt;/strong&gt; Validates that the user is logged in.&lt;/li&gt;
  1524. &lt;li&gt;&lt;strong&gt;RequireAnonymous&lt;/strong&gt; Validates that the user is NOT logged in.&lt;/li&gt;
  1525. &lt;li&gt;&lt;strong&gt;RequireRole&lt;/strong&gt; Validates that the user is in the specified role.&lt;/li&gt;
  1526. &lt;li&gt;&lt;strong&gt;RequireAnyRole&lt;/strong&gt; Validates that the user is in at least one of the specified roles.&lt;/li&gt;
  1527. &lt;li&gt;&lt;strong&gt;RequireEachRole&lt;/strong&gt; Validates that the user is in every one of the specified roles.&lt;/li&gt;
  1528. &lt;/ul&gt;
  1529.  
  1530. &lt;p&gt;Let&amp;#39;s imagine a controller for a simple bulletin board system. In order to post to this forum you must be logged in, if you want to delete a post you must be in either the &amp;quot;Administrators&amp;quot; role or the &amp;quot;Moderators&amp;quot; role, and if you want to undelete a post you must be in the &amp;quot;Administrators&amp;quot; group. That controller would look something like:&lt;/p&gt;
  1531.  
  1532. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-7.cs&quot;&gt; &lt;/script&gt;
  1533.  
  1534. &lt;p&gt;By applying the [&lt;strong&gt;RequireLogin&lt;/strong&gt;] attribute to the class you have applied that filter to all of the actions as well, which means you must be logged in to call the &lt;strong&gt;Post&lt;/strong&gt; method. The other two methods use the appropriate version of the role requirement filters to achieve their goal.&lt;/p&gt;
  1535.  
  1536. &lt;p&gt;What happens if the filter validations fail? In the case of an anonymous user attempting to access a restricted resource an &lt;strong&gt;AnonymousAccessException&lt;/strong&gt; (which derives from &lt;strong&gt;SecurityException&lt;/strong&gt;) is thrown while all other scenarios throw a &lt;strong&gt;SecurityException&lt;/strong&gt;. What you do with those exceptions leads us to...&lt;/p&gt;
  1537.  
  1538. &lt;h2&gt;Error Handler Filter&lt;/h2&gt;
  1539.  
  1540. &lt;p&gt;Using the above &lt;strong&gt;ForumController&lt;/strong&gt;, let&amp;#39;s add the &lt;strong&gt;ErrorHandler&lt;/strong&gt; filter:&lt;/p&gt;
  1541.  
  1542. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-8.cs&quot;&gt; &lt;/script&gt;
  1543.  
  1544. &lt;p&gt;Like with the last filter, this filter by itself does nothing but allow us to use the &lt;strong&gt;ErrorHandler&lt;/strong&gt; sub-filter. Let&amp;#39;s go ahead and add two sub-filters: one to handle security exceptions and one to handle all other exceptions.&lt;/p&gt;
  1545.  
  1546. &lt;p&gt;In the event of a security exception we&amp;#39;ll render the &amp;quot;AccessDenied&amp;quot; view while all other exceptions will render the &amp;quot;SystemError&amp;quot; view:&lt;/p&gt;
  1547.  
  1548. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-9.cs&quot;&gt; &lt;/script&gt;
  1549.  
  1550. &lt;p&gt;First notice that we are now providing the &lt;strong&gt;ErrorHandlerFilter&lt;/strong&gt; attribute with an option that says &lt;strong&gt;ErrorHandlerMode.Render&lt;/strong&gt;. This is because in the event of an error we want the controller to render the view with the name passed in. Later on we&amp;#39;ll look at the other mode: &lt;strong&gt;ErrorHandlerMode.Redirect&lt;/strong&gt;.&lt;/p&gt;
  1551.  
  1552. &lt;p&gt;Next notice that we are providing three values to each of the two &lt;strong&gt;ErrorHandler&lt;/strong&gt; sub-filters:&lt;/p&gt;
  1553.  
  1554. &lt;ul&gt;
  1555. &lt;li&gt;The order in which the sub-filter should be processed. This is important because the order the attribute is returned by reflection is unknown.&lt;/li&gt;
  1556. &lt;li&gt;The name of the view to render. Just like calling &lt;strong&gt;RenderView&lt;/strong&gt;() from an action, this view name must be accessible to the controller (either in the controller&amp;#39;s view directory or in the &lt;strong&gt;Shared&lt;/strong&gt; directory).&lt;/li&gt;
  1557. &lt;li&gt;The type of the exception to match against.&lt;/li&gt;
  1558. &lt;/ul&gt;
  1559.  
  1560. &lt;p&gt;Keep in mind that these sub-filters could be applied at either the class level or the method level and that method-level sub-filters are processed before class-level sub-filters. We&amp;#39;ll stick with class-level throughout this article.&lt;/p&gt;
  1561.  
  1562. &lt;p&gt;An &amp;quot;Access Denied&amp;quot; page popping up whenever we try to go somewhere we aren&amp;#39;t allowed to without logging in isn&amp;#39;t the best user experience. Let&amp;#39;s improve it by sending anonymous users to the login page instead. This time however, we don&amp;#39;t want just render the login view, we want to actually redirect to the &lt;strong&gt;SecurityController&lt;/strong&gt;&amp;#39;s &lt;strong&gt;Login&lt;/strong&gt; action. While we&amp;#39;re at it, I&amp;#39;ll show you an example of handling multiple exceptions with one sub-filter:&lt;/p&gt;
  1563.  
  1564. &lt;script src=&quot;https://gist.github.com/4007528.js?file=Example-10.cs&quot;&gt; &lt;/script&gt;
  1565.  
  1566. &lt;p&gt;Here in line 1 we specify not the name of the view to render, but the name of the action and controller to redirect to (in the format &amp;quot;action,controller&amp;quot;). The handler knows to process this as a redirect because we&amp;#39;ve changed the mode for this one sub-filter to &lt;strong&gt;ErrorHandlerMode.Redirect&lt;/strong&gt;. Lines 7, 8, &amp;amp; 9 illustrate the capability for one sub-filter to match against many exceptions.&lt;/p&gt;
  1567.  
  1568. &lt;h2&gt;Download The Code&lt;/h2&gt;
  1569.  
  1570. &lt;p&gt;I hope you find these filters useful. If they don&amp;#39;t happen to match your particular problem, then feel free to write your own filters. To do so you only have to implement the &lt;strong&gt;IControllerFilter&lt;/strong&gt; interface. I&amp;#39;ve attempted to make it even easier to do so by providing a base class named &lt;strong&gt;ControllerFilter&lt;/strong&gt; that already implements the interface and has several hooks for you to take advantage of.&lt;/p&gt;
  1571.  
  1572. &lt;p&gt;You are free to use or modify this code for anything including commercial purposes. The only restriction I ask is that you do not take credit for this work yourself, but I do not require any specific attribution.&lt;/p&gt;
  1573.  
  1574. &lt;p&gt;I have packaged the code into four different releases:&lt;/p&gt;
  1575.  
  1576. &lt;p class=&quot;warning&quot;&gt;These projects were built on Vista x64. If you are running a 32-bit version of Windows you may initially have trouble building the source versions below. To fix this you&#39;ll need to re-add the System.Web.Extensions reference. &lt;a href=&quot;#comment-152106318&quot;&gt;See my comment below for more details.&lt;/a&gt;&lt;/p&gt;
  1577.  
  1578. &lt;p&gt;*&lt;em&gt;Full Source Release
  1579. *&lt;/em&gt;The entire solution zipped up.
  1580. &lt;a href=&quot;/custom/files/old/MVC+Controller+Filters+(Source+and+Example+Website).zip&quot;&gt;MVC+Controller+Filters+(Source+and+Example+Website).zip&lt;/a&gt;&lt;/p&gt;
  1581.  
  1582. &lt;p&gt;&lt;strong&gt;Example Site &amp;amp; Binaries Release&lt;/strong&gt;
  1583. &lt;strong&gt;(Recommended)&lt;/strong&gt; Just the binaries zipped up with an example site.
  1584. &lt;a href=&quot;/custom/files/old/MVC+Controller+Filters+(Example+Website).zip&quot;&gt;MVC+Controller+Filters+(Example+Website).zip&lt;/a&gt;&lt;/p&gt;
  1585.  
  1586. &lt;p&gt;&lt;strong&gt;Filter Source Release&lt;/strong&gt;
  1587. The source code for the FilterController and filters. No example site.
  1588. &lt;a href=&quot;/custom/files/old/MVC+Controller+Filters+(Source).zip&quot;&gt;MVC+Controller+Filters+(Source).zip&lt;/a&gt;&lt;/p&gt;
  1589.  
  1590. &lt;p&gt;&lt;strong&gt;Filter Binaries Release&lt;/strong&gt;
  1591. The binaries for the FilterController and filters only. No source.
  1592. &lt;a href=&quot;/custom/files/old/MVC+Controller+Filters+(Binaries).zip&quot;&gt;MVC+Controller+Filters+(Binaries).zip&lt;/a&gt;&lt;/p&gt;
  1593. </content>
  1594. </entry>
  1595. <entry>
  1596.   <title>MVC Template Fix</title>
  1597.   <link href="http://www.squaredroot.com/2008/01/02/mvc-template-fix/"/>
  1598.   <updated>2008-01-02T00:00:00+00:00</updated>
  1599.   <id>http://www.squaredroot.com/2008/01/02/mvc-template-fix</id>
  1600.   <content type="html">&lt;p&gt;Several weeks ago &lt;a href=&quot;/2007/12/11/mvc-bug-broken-codebehind/&quot;&gt;I blogged about a bug&lt;/a&gt; I found in the &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-3-5-extensions-ctp-preview-released.aspx&quot;&gt;CTP release of the MVC framework&lt;/a&gt;. The gist of the bug is that controls declared in the html portion of a page or user control could not be referenced from the code-behind of that page or user control. ScottGu posted a comment clarifying that &lt;a href=&quot;/2007/12/11/mvc-bug-broken-codebehind/#comment-152106388&quot;&gt;this was due to a bug in the templates&lt;/a&gt; released in the CTP. &lt;/p&gt;
  1601.  
  1602. &lt;p&gt;After nearly a month of following Scott&amp;#39;s advice on how to fix the bug, I finally grew tired of such a repetitive task and have fixed the templates. You&amp;#39;ll find a zip file containing the fix and installation instructions at the bottom of this post. Before I get into that though, let me explain the workaround (suggested by ScottGu) that I&amp;#39;ve been using until now: &lt;/p&gt;
  1603.  
  1604. &lt;h2&gt;The Easy, Repetitive Workaround&lt;/h2&gt;
  1605.  
  1606. &lt;p&gt;The problem is that the template for pages, master pages, and user controls only include the declarative HTML file and it&amp;#39;s code-behind. The template is missing the designer file used by Visual Studio to hide the references generated by the server controls declared in your HTML. Here is what a MVC page looks like right after creation: &lt;/p&gt;
  1607.  
  1608. &lt;p&gt;&lt;img src=&quot;/custom/files/old/SimpleWorkaround-Before_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  1609.  
  1610. &lt;p&gt;You could manually create a designer class to fix this issue, but that would be a pain. Luckily Visual Studio provides us with the handy &amp;quot;Convert to Web Application&amp;quot; feature to generate the designer class for us. Simply right-click on the .ASPX (or .Master or .ASCX) and click the &amp;quot;Convert to Web Application&amp;quot; option on the context menu. &lt;/p&gt;
  1611.  
  1612. &lt;p&gt;&lt;img src=&quot;/custom/files/old/SimpleWorkaround-During_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  1613.  
  1614. &lt;p&gt;After doing so, you should see this: &lt;/p&gt;
  1615.  
  1616. &lt;p&gt;&lt;img src=&quot;/custom/files/old/SimpleWorkaround-After_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  1617.  
  1618. &lt;p&gt;&lt;em&gt;Voil&amp;agrave;&lt;/em&gt;! Your codebehind file for that page/control (and that page/control only) should now work as expected. Its quick and simple, but I&amp;#39;m sure you can imagine already the annoyance at having to do this for each and every page or control you create. That thought leads us to... &lt;/p&gt;
  1619.  
  1620. &lt;h2&gt;The Slightly More Complex Permanent Solution&lt;/h2&gt;
  1621.  
  1622. &lt;p&gt;First, an admission of guilt: I only fixed the C# templates. I apologize to any VB.Net&amp;#39;ers out there ahead of time. &lt;/p&gt;
  1623.  
  1624. &lt;p&gt;There are four templates that must be fixed: &lt;/p&gt;
  1625.  
  1626. &lt;ul&gt;
  1627. &lt;li&gt;View Master Page - A master page.&lt;/li&gt;
  1628. &lt;li&gt;View Page - A normal page.&lt;/li&gt;
  1629. &lt;li&gt;View Content Page - A page that uses a master page.&lt;/li&gt;
  1630. &lt;li&gt;View User Control - A control.&lt;/li&gt;
  1631. &lt;/ul&gt;
  1632.  
  1633. &lt;p&gt;These four templates are found in two different places: the &lt;em&gt;item templates&lt;/em&gt; folder and the item &lt;em&gt;templates cache&lt;/em&gt; folder. &lt;/p&gt;
  1634.  
  1635. &lt;p&gt;Those folders are found at: &amp;quot;&lt;em&gt;Common7IDEItemTemplatesCSharpWeb1033&lt;/em&gt;&amp;quot; and &amp;quot;&lt;em&gt;Common7IDEItemTemplatesCacheCSharpWeb1033&lt;/em&gt;&amp;quot; respectively (within your VS 9 root folder). &lt;/p&gt;
  1636.  
  1637. &lt;p&gt;The item templates folder contains zip files which are at some point unzipped and stored in the item &lt;em&gt;templates cache&lt;/em&gt; folder. I suppose you could just update the contents of the &lt;em&gt;item templates cache&lt;/em&gt; folder, but I don&amp;#39;t know if those settings would ever be written over by the &lt;em&gt;item templates&lt;/em&gt; folder, so it is better to be safe and fix it in both places. &lt;/p&gt;
  1638.  
  1639. &lt;p&gt;&lt;img src=&quot;/custom/files/old/TemplateFix-ZipLocation_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  1640.  
  1641. &lt;p&gt;&lt;img src=&quot;/custom/files/old/TemplateFix-CacheLocation_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  1642.  
  1643. &lt;p&gt;The contents of a typical template for pages/user controls are: &lt;/p&gt;
  1644.  
  1645. &lt;ul&gt;
  1646. &lt;li&gt;a &lt;em&gt;vtemplate&lt;/em&gt; file (which serves as the manifest for the rest of the items)&lt;/li&gt;
  1647. &lt;li&gt;an icon file&lt;/li&gt;
  1648. &lt;li&gt;an html file (ASPX, ASCX, etc)&lt;/li&gt;
  1649. &lt;li&gt;a codebehind file&lt;/li&gt;
  1650. &lt;li&gt;a designer file&lt;/li&gt;
  1651. &lt;/ul&gt;
  1652.  
  1653. &lt;p&gt;As you can see from the screenshot below, the templates did not include a designer file. &lt;/p&gt;
  1654.  
  1655. &lt;p&gt;&lt;img src=&quot;/custom/files/old/TemplateFix-ZipContents_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  1656.  
  1657. &lt;p&gt;In addition, the vtemplate file does not describe a designer file. &lt;/p&gt;
  1658.  
  1659. &lt;p&gt;&lt;img src=&quot;/custom/files/old/TemplateFix-TemplateFile_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  1660.  
  1661. &lt;p&gt;The fix is to add a line to the vtemplate file referencing a designer file and then add the designer file itself to the template folder/zip. The designer file should look something like: &lt;/p&gt;
  1662.  
  1663. &lt;p&gt;&lt;img src=&quot;/custom/files/old/TemplateFix-DesignerFile_2.jpg&quot; alt=&quot;IMAGE&quot;&gt; &lt;/p&gt;
  1664.  
  1665. &lt;p&gt;I&amp;#39;ve gone ahead and done all this for you -- well, actually for me, but you get the point. :-) All you need to do is download the zip file from below and follow the instructions included in the readme.txt file.&lt;/p&gt;
  1666.  
  1667. &lt;p&gt;&lt;a href=&quot;/custom/files/old/MVC+Template+Fix.zip&quot;&gt;MVC+Template+Fix.zip&lt;/a&gt;&lt;/p&gt;
  1668. </content>
  1669. </entry>
  1670. <entry>
  1671.   <title>MVC: ViewData vs. TempData</title>
  1672.   <link href="http://www.squaredroot.com/2007/12/20/mvc-viewdata-vs-tempdata/"/>
  1673.   <updated>2007-12-20T00:00:00+00:00</updated>
  1674.   <id>http://www.squaredroot.com/2007/12/20/mvc-viewdata-vs-tempdata</id>
  1675.   <content type="html">&lt;p class=&quot;warning&quot;&gt;This article was written for the December CTP release of the MVC framework. Unfortunately, it does not entirely apply to the Preview 2 release or subsequent releases.&lt;/p&gt;
  1676.  
  1677. &lt;p&gt;A commenter (&lt;a href=&quot;http://www.superwasp.net/weblog/&quot;&gt;oVan&lt;/a&gt;) recently &lt;a href=&quot;/2007/12/10/aspnet-mvc-membership-basics/#comment-152106519&quot;&gt;left a comment&lt;/a&gt; on one of my posts with a suggestion to redirect to a different URL rather than display a different view. He cautioned that if I do so to make certain I use store data in the TempData dictionary rather than ViewData. I had not yet heard of the TempData dictionary, so I set off into &lt;a href=&quot;http://www.aisto.com/roeder/dotnet/&quot;&gt;Reflector&lt;/a&gt; to find out what exactly it is.&lt;/p&gt;
  1678.  
  1679. &lt;p&gt;Initially it appeared that TempData was simply a Dictionary&amp;lt;string,object&amp;gt; stored in session. This is close to the truth, but not the whole truth. In fact the internal declaration of TempData&amp;#39;s storage device is:&lt;/p&gt;
  1680.  
  1681. &lt;script src=&quot;https://gist.github.com/3998629.js?file=Example-1.cs&quot;&gt; &lt;/script&gt;
  1682.  
  1683. &lt;p&gt;Why such a complicated declaration? Further digging revealed that the second element of the pair (the HashSet) is used as a kind of key synchronization device. When an item is added to the internal storage, the key is placed in the HashSet. At some point that I have been unable to determine, the key is removed from the HashSet. Then when the TempData object is built again, the discrepancy is noticed and the Dictionary entry that has a key not contained in the HashSet is removed from the Dictionary.  &lt;/p&gt;
  1684.  
  1685. &lt;p&gt;The end result is that &lt;strong&gt;any data stored in TempData will be around for the life the current request and the next request only&lt;/strong&gt;, or until the item is removed explicitly. This is useful when you want to pass data to another view that you will be redirecting to, rather than rendering to.  &lt;/p&gt;
  1686.  
  1687. &lt;script src=&quot;https://gist.github.com/3998629.js?file=Example-2.cs&quot;&gt; &lt;/script&gt;
  1688.  
  1689. &lt;p&gt;In the code above if you navigate to the Index page, you are automatically redirected to the Test1 action&amp;#39;s URL. The Test1 action then executes and is able to access the data stored for it in TempData. If you then navigate to the Test2 action, that action is unable to retrieve the data previously stored in TempData.&lt;/p&gt;
  1690.  
  1691. &lt;p&gt;To retrieve data from TempData inside of a view, do the following:&lt;/p&gt;
  1692.  
  1693. &lt;script src=&quot;https://gist.github.com/3998629.js?file=Example-3.aspx&quot;&gt; &lt;/script&gt;
  1694.  
  1695. &lt;p&gt;One suggestion for an improvement in the next CTP would be to have all data available in TempData copied over to ViewData at the beginning of a request (after the old TempData has been cleared). This would allow us to simply say:&lt;/p&gt;
  1696.  
  1697. &lt;script src=&quot;https://gist.github.com/3998629.js?file=Example-4.aspx&quot;&gt; &lt;/script&gt;
  1698.  
  1699. &lt;p&gt;Otherwise the view has to be very aware of the controller and how it plans to pass data into the view. Currently I cannot have a view that supports being passed data both ways without doing the following:  &lt;/p&gt;
  1700.  
  1701. &lt;script src=&quot;https://gist.github.com/3998629.js?file=Example-5.aspx&quot;&gt; &lt;/script&gt;
  1702. </content>
  1703. </entry>
  1704. <entry>
  1705.   <title>MVC Complaint: Checkboxes</title>
  1706.   <link href="http://www.squaredroot.com/2007/12/11/mvc-checkboxes-complaint/"/>
  1707.   <updated>2007-12-11T00:00:00+00:00</updated>
  1708.   <id>http://www.squaredroot.com/2007/12/11/mvc-checkboxes-complaint</id>
  1709.   <content type="html">&lt;p class=&quot;warning&quot;&gt;This article was written for the December CTP release of the MVC framework. Unfortunately, it does not entirely apply to the Preview 2 release or subsequent releases.&lt;/p&gt;
  1710.  
  1711. &lt;p&gt;I mentioned in my previous post on &lt;a href=&quot;/2007/12/10/aspnet-mvc-membership-basics/&quot;&gt;building login &amp;amp; registration forms&lt;/a&gt; in the &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-3-5-extensions-ctp-preview-released.aspx&quot;&gt;ASP.NET MVC framework&lt;/a&gt; that I was not a fan of the way checkboxes are handled in the first CTP release&amp;#39;s &lt;a href=&quot;http://blog.wekeroad.com/2007/12/05/aspnet-mvc-preview-using-the-mvc-ui-helpers/&quot;&gt;toolkit&lt;/a&gt;. To help explain why I don&amp;#39;t care for it, consider the following... what would you expect the following helper function to output?&lt;/p&gt;
  1712.  
  1713. &lt;script src=&quot;https://gist.github.com/3998609.js?file=Example-1.aspx&quot;&gt; &lt;/script&gt;
  1714.  
  1715. &lt;p&gt;I would imagine a single checkbox and a label with the text value, which is incorrect. Instead, this is what is generated:&lt;/p&gt;
  1716.  
  1717. &lt;script src=&quot;https://gist.github.com/3998609.js?file=Example-2.html&quot;&gt; &lt;/script&gt;
  1718.  
  1719. &lt;p&gt;It looks fairly reasonable to most and really isn&amp;#39;t the end of the world, but is rather unusable in my eyes. The text is just output inline directly following the checkbox element with no element wrapping it. This small omission makes it incredibly difficult to style the output effectively using CSS. Simply wrap the text in a &amp;lt;label&amp;gt; element and everything is gravy. What I would prefer to see output is:&lt;/p&gt;
  1720.  
  1721. &lt;script src=&quot;https://gist.github.com/3998609.js?file=Example-3.html&quot;&gt; &lt;/script&gt;
  1722.  
  1723. &lt;p&gt;I realize this seems like a nitpick; I&amp;#39;m perfectly capable of writing my own HTML checkbox and label (usually). My frustrations do not end there, though; let&amp;#39;s look at how you retrieve data from a checkbox within a controller action that you have posted to. Taking the example of a simple login form with two text fields (&amp;quot;userName&amp;quot; and &amp;quot;password&amp;quot;) and one checkbox (&amp;quot;rememberMe&amp;quot;) you might expect to have the following controller action:&lt;/p&gt;
  1724.  
  1725. &lt;script src=&quot;https://gist.github.com/3998609.js?file=Example-4.cs&quot;&gt; &lt;/script&gt;
  1726.  
  1727. &lt;p&gt;Given the context of this article, you can probably guess that the above doesn&amp;#39;t work. Unfortunately the automagic code that maps fields found in the HTTP request to parameters in a controller action does not support mapping to a boolean. This is partly the fault of the HTTP spec (submitting a checked checkbox causes the form to post with $NAME=$VALUE where $NAME is the name of the checkbox element and $VALUE is the value of the &amp;quot;value&amp;quot; attribute; submitting an unchecked checkbox causes the form to post without any reference to the checkbox -- i.e.: a null value), but could easily be resolved with the following rule:&lt;/p&gt;
  1728.  
  1729. &lt;p&gt;&lt;strong&gt;When a boolean is declared in a method marked with [ControllerAction], pass false into the parameter unless a text value is found with a field name that correlates to the name of the parameter (in which case pass true).&lt;/strong&gt;&lt;/p&gt;
  1730.  
  1731. &lt;p&gt;In other words, if you can&amp;#39;t find a mention of &amp;quot;rememberMe&amp;quot; in the form&amp;#39;s POST data, pass false to the parameter. If the form&amp;#39;s POST data contains *any *value for a field named &amp;quot;rememberMe,&amp;quot; pass true to the parameter. For the time being you should declare the checkbox parameter as a string and test it against null, like so:&lt;/p&gt;
  1732.  
  1733. &lt;script src=&quot;https://gist.github.com/3998609.js?file=Example-5.cs&quot;&gt; &lt;/script&gt;
  1734.  
  1735. &lt;p&gt;Sure, it isn&amp;#39;t rocket science the way it is setup right now, but a little extra work could make for a much more fluid learning curve for new MVC developers. Obviously this is just a CTP release and not the full deal; I fully expect a lot of these quirks to be worked out over the next several months. This does make me wonder, will the toolkit be posted to &lt;a href=&quot;http://www.codeplex.com&quot;&gt;CodePlex&lt;/a&gt; so that it can benefit from community involvement?&lt;/p&gt;
  1736. </content>
  1737. </entry>
  1738. <entry>
  1739.   <title>MVC Bug: Broken Codebehind</title>
  1740.   <link href="http://www.squaredroot.com/2007/12/11/mvc-bug-broken-codebehind/"/>
  1741.   <updated>2007-12-11T00:00:00+00:00</updated>
  1742.   <id>http://www.squaredroot.com/2007/12/11/mvc-bug-broken-codebehind</id>
  1743.   <content type="html">&lt;p class=&quot;warning&quot;&gt;This post is no longer relevant with recent releases of ASP.NET MVC.&lt;/p&gt;
  1744.  
  1745. &lt;p&gt;&lt;strong&gt;Update (Jan 2):&lt;/strong&gt; I have posted &lt;a href=&quot;/2008/01/02/mvc-template-fix/&quot;&gt;a permanent fix in the form of modified Visual Studio templates in another blog post&lt;/a&gt;.&lt;/p&gt;
  1746.  
  1747. &lt;p&gt;&lt;strong&gt;Update (Dec 11):&lt;/strong&gt; ScottGu was kind enough to &lt;a href=&quot;#comment-152106388&quot;&gt;post a fix for this particular problem&lt;/a&gt;. It is unfortunate that you have to repeat the fix for every view you add to your project, but I guess that&amp;#39;s why it is called a CTP! ScottGu said... &lt;/p&gt;
  1748.  
  1749. &lt;blockquote&gt;
  1750. There is a bug in the file template when you create a new page - and the .designer.cs file isn&#39;t generated.
  1751.    
  1752. To fix this, right click on the file and choose the &quot;Convert to Web Application&quot; menu item. This will generate the .designer.cs file that contains your control declarations. From that point on the code-behind will be kept up to date as you make changes.
  1753.  
  1754. Hope this helps,
  1755.  
  1756. Scott
  1757. &lt;/blockquote&gt;
  1758.  
  1759. &lt;p&gt;&lt;strong&gt;Original Post:&lt;/strong&gt;&lt;/p&gt;
  1760.  
  1761. &lt;p&gt;It may not be a popular choice, but I&amp;#39;m perfectly okay with in-line code in my views as long as it doesn&amp;#39;t contain business logic. One of the developers on my project prefers tag-based views (&amp;lt;asp:Blah runat=&amp;quot;server&amp;quot; /&amp;gt;) and came to me yesterday with a curious issue. I&amp;#39;ve spent some of the morning investigating the issue and it does appear that there is a bug in the &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-3-5-extensions-ctp-preview-released.aspx&quot;&gt;newly released ASP.Net MVC Framework&lt;/a&gt;.&lt;/p&gt;
  1762.  
  1763. &lt;p&gt;The issue? &lt;strong&gt;Controls declared in an ASPX are not visible to that page&amp;#39;s codebehind.&lt;/strong&gt;&lt;/p&gt;
  1764.  
  1765. &lt;p&gt;To test this hypothesis (and make sure we hadn&amp;#39;t somehow broken our project) I started a new &amp;quot;ASP.Net MVC Web Application&amp;quot; project (note that the bug also exists for the &amp;quot;ASP.Net MVC Web Application and Test&amp;quot; project). I then opened the Views/Home/About.aspx file and added the following line:&lt;/p&gt;
  1766.  
  1767. &lt;script src=&quot;https://gist.github.com/3998555.js?file=About.aspx&quot;&gt; &lt;/script&gt;
  1768.  
  1769. &lt;p&gt;Then I opened up the page&amp;#39;s codebehind (Views/Home/About.aspx.cs) and added the following:&lt;/p&gt;
  1770.  
  1771. &lt;script src=&quot;https://gist.github.com/3998555.js?file=About.aspx.cs&quot;&gt; &lt;/script&gt;
  1772.  
  1773. &lt;p&gt;Ctrl+Shift+B to compile and bam, a build error: &lt;strong&gt;&amp;quot;The name &amp;#39;myLiteral&amp;#39; does not exist in the current context.&amp;quot;&lt;/strong&gt;&lt;/p&gt;
  1774.  
  1775. &lt;p&gt;I began to wonder if this was not supported by the MVC framework, but I took a look back at one of ScottGu&amp;#39;s most recent articles, &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2007/12/06/asp-net-mvc-framework-part-3-passing-viewdata-from-controllers-to-views.aspx&quot;&gt;ASP.Net MVC Framework (Part 3): Passing ViewData from Controllers to Views&lt;/a&gt;, and saw that he references controls from the page&amp;#39;s codebehind several times. I also tried using several controls besides the Literal to no avail. &lt;/p&gt;
  1776.  
  1777. &lt;p&gt;To test what was going on, I commented out the reference in the Page_Load method, added a string declaration and put a breakpoint on it. When I ran the MVC application in debug mode and loaded the page I was able to see the &amp;quot;myLiteral&amp;quot; control reference. It appears that the reference is available at runtime but Visual Studio just is not able to see it at compile time. Odd. &lt;/p&gt;
  1778.  
  1779. &lt;p&gt;&lt;img src=&quot;/custom/files/old/DebugMyLiteral.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1780.  
  1781. &lt;p&gt;For now I&amp;#39;ve told the developer to just use in-line code, but I&amp;#39;m well aware that many developers are loathe to do so. Thoughts? Suggestions?&lt;/p&gt;
  1782. </content>
  1783. </entry>
  1784. <entry>
  1785.   <title>ASP.Net MVC Membership Basics</title>
  1786.   <link href="http://www.squaredroot.com/2007/12/10/aspnet-mvc-membership-basics/"/>
  1787.   <updated>2007-12-10T00:00:00+00:00</updated>
  1788.   <id>http://www.squaredroot.com/2007/12/10/aspnet-mvc-membership-basics</id>
  1789.   <content type="html">&lt;p class=&quot;warning&quot;&gt;This article was written for the December 2007 CTP release of the MVC framework. It does not entirely apply to the Preview 2 release or subsequent releases.&lt;/p&gt;
  1790.  
  1791. &lt;p&gt;&lt;a href=&quot;http://asp.net/downloads/3.5-extensions/&quot;&gt;The MVC bits have finally arrived&lt;/a&gt; and I&amp;#39;ve spent a while digesting them. I&amp;#39;ve been waiting for the bits to be released to begin working on a side-project, so the first thing I did after downloading them last night was crank it up and start working on a new ASP.NET MVC Web Application project.&lt;/p&gt;
  1792.  
  1793. &lt;p&gt;Typically, the first thing I do on a new project is set up the authentication/authorization system. For the project I am working on I want to use the ASP.Net Membership system, but most of the Membership controls do not work with the MVC framework because they require postbacks. I spent some time last night building a Security controller and views for Registration and Login that I thought would be worth sharing.&lt;/p&gt;
  1794.  
  1795. &lt;p&gt;So far I have implemented basic functionality for Register, Login, and Logout. There are three files we will have to create. We will also have to change the routing table. Let&amp;#39;s start with the SecurityController:&lt;/p&gt;
  1796.  
  1797. &lt;script src=&quot;https://gist.github.com/3998394.js?file=SecurityController.cs&quot;&gt; &lt;/script&gt;
  1798.  
  1799. &lt;p&gt;So we have two basic actions methods that only display views (Register and Login) and three action-only methods that have no views (CreateUser, Authenticate, Logout).&lt;/p&gt;
  1800.  
  1801. &lt;p&gt;I have chosen to not have a logout page, but to instead redirect to the homepage. Switch out &amp;#39;Response.Redirect( &amp;quot;/&amp;quot; );&amp;#39; for &amp;#39;RenderView( &amp;quot;Logout&amp;quot; );&amp;#39; and create a Logout.aspx view if you would like to display a logout message.&lt;/p&gt;
  1802.  
  1803. &lt;p&gt;Now let&amp;#39;s look at the Login view:&lt;/p&gt;
  1804.  
  1805. &lt;script src=&quot;https://gist.github.com/3998394.js?file=LoginView.aspx&quot;&gt; &lt;/script&gt;
  1806.  
  1807. &lt;p&gt;The toolkit&amp;#39;s Html.Checkbox(...) method annoys me. More on why in another post. For now I&amp;#39;ve instead just written the html out by hand. You&amp;#39;ll note I&amp;#39;ve also linked the label to the checkbox with JavaScript so that clicking the label toggles the checkbox.&lt;/p&gt;
  1808.  
  1809. &lt;p&gt;Then the Register view:&lt;/p&gt;
  1810.  
  1811. &lt;script src=&quot;https://gist.github.com/3998394.js?file=RegisterView.aspx&quot;&gt; &lt;/script&gt;
  1812.  
  1813. &lt;p&gt;Another straightforward view. Not much to discuss here.&lt;/p&gt;
  1814.  
  1815. &lt;p&gt;And finally, let&amp;#39;s add the new routes:&lt;/p&gt;
  1816.  
  1817. &lt;script src=&quot;https://gist.github.com/3998394.js?file=global.asax.cs&quot;&gt; &lt;/script&gt;
  1818.  
  1819. &lt;p&gt;I personally like login to be &amp;quot;http://website/login&amp;quot; and register to be &amp;quot;http://website/register&amp;quot;, so that is how I have configured it. The other three actions (Logout, Authenticate, and CreateUser) I access via the default route (ex: /Security/Logout).&lt;/p&gt;
  1820.  
  1821. &lt;p&gt;That&amp;#39;s it! You should now have a working registration/login system. I&amp;#39;ll leave making it pretty with CSS as an exercise for the reader.&lt;/p&gt;
  1822.  
  1823. &lt;p&gt;I have included all of the code samples above in the below ZIP file. Just unzip it and place the controller into the Controllers directory, the views into the Views/Security directory (which you will have to create), and copy the code from Routes.txt to the appropriate area of your Global.asax.&lt;/p&gt;
  1824.  
  1825. &lt;p&gt;&lt;a href=&quot;/custom/files/old/MVCMembership_v1.2.zip&quot;&gt;MVCMembership_v1.2.zip&lt;/a&gt;&lt;/p&gt;
  1826.  
  1827. &lt;p&gt;&lt;a name=&quot;update-dec-11&quot;&gt;&lt;/a&gt;
  1828. &lt;strong&gt;UPDATE (Dec 11):&lt;/strong&gt; Johan and &lt;a href=&quot;http://stevenharman.net/&quot;&gt;Steve Harman&lt;/a&gt; were kind enough to &lt;a href=&quot;#comment-152106495&quot;&gt;point out&lt;/a&gt; that I had foolishly set the &amp;quot;remember me&amp;quot; checkbox&amp;#39;s label&amp;#39;s &amp;quot;for&amp;quot; attribute to point to the password field instead of the checkbox itself. I have fixed the code above and provided a new zip file (1.1) for download. Thanks guys!&lt;/p&gt;
  1829.  
  1830. &lt;p&gt;&lt;a name=&quot;update-dec-19&quot;&gt;&lt;/a&gt;
  1831. &lt;strong&gt;Update (Dec 19):&lt;/strong&gt; &lt;a href=&quot;http://www.superwasp.net/weblog/&quot;&gt;oVan&lt;/a&gt; &lt;a href=&quot;#comment-152106514&quot;&gt;pointed out a bug&lt;/a&gt; in the routing rules defined in the routes.txt file. I have updated the zip file with the correct code. Thanks oVan!&lt;/p&gt;
  1832.  
  1833. &lt;p&gt;&lt;a name=&quot;update-jan-3&quot;&gt;&lt;/a&gt;
  1834. &lt;strong&gt;Update (Jan 3):&lt;/strong&gt; &lt;a href=&quot;#comment-152106536&quot;&gt;James Nail asked a very good question via a comment&lt;/a&gt;: what do you set for the loginUrl and defaultUrl in your web.config? Well James, here is how I&amp;#39;ve setup my web.config...&lt;/p&gt;
  1835.  
  1836. &lt;p&gt;Assuming we&amp;#39;ll be using forms authentication and securing all pages except login and the homepage, place the following inside the &amp;lt;system.web&amp;gt; element:&lt;/p&gt;
  1837.  
  1838. &lt;script src=&quot;https://gist.github.com/3998394.js?file=webconfig-1.xml&quot;&gt; &lt;/script&gt;
  1839.  
  1840. &lt;p&gt;Then, somewhere outside the &amp;lt;system.web&amp;gt; element add:&lt;/p&gt;
  1841.  
  1842. &lt;script src=&quot;https://gist.github.com/3998394.js?file=webconfig-2.xml&quot;&gt; &lt;/script&gt;
  1843.  
  1844. &lt;p&gt;Note that this will grant access to all actions within the Security controller. It is also worth pointing out that, dependent on your setup, your CSS and image files may not load unless you also create a location path for their directory and grant all users access like so:&lt;/p&gt;
  1845.  
  1846. &lt;script src=&quot;https://gist.github.com/3998394.js?file=webconfig-3.xml&quot;&gt; &lt;/script&gt;
  1847.  
  1848. &lt;p&gt;I have not updated the zip file with these web.config settings; let me know if anyone would prefer that I add it. I hope this helps some of you!&lt;/p&gt;
  1849. </content>
  1850. </entry>
  1851. <entry>
  1852.   <title>MVC.net Release TODAY!</title>
  1853.   <link href="http://www.squaredroot.com/2007/12/09/mvcnet-release-today/"/>
  1854.   <updated>2007-12-09T00:00:00+00:00</updated>
  1855.   <id>http://www.squaredroot.com/2007/12/09/mvcnet-release-today</id>
  1856.   <content type="html">&lt;p&gt;Scott Guthrie posted a comment to his &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-mvc-framework-part-4-handling-form-edit-and-post-scenarios.aspx#5425465&quot;&gt;fourth entry in his ASP.Net MVC tutorial series&lt;/a&gt; stating: &lt;/p&gt;
  1857.  
  1858. &lt;blockquote&gt;
  1859. Sunday, December 09, 2007 8:00 AM by ScottGu
  1860. Hi Panjkov,
  1861.  
  1862. &gt;&gt;&gt;&gt;&gt;&gt; is this correct link for asp.net extensions preview that will be shipped (today?) go.microsoft.com/fwlink (taken from www.hunterstrat.com/.../microsoft-releases-adonet-entity-framework-aspnet-35-extensions-previews )
  1863.  
  1864. No - that is for the ADO.NET entities bits (which is something different).  Keep an eye on www.asp.net in a few hours - the ASP.NET 3.5 Extensions Preview (which includes MVC) will be posted there shortly.
  1865.  
  1866. Thanks,
  1867.  
  1868. Scott
  1869. &lt;/blockquote&gt;
  1870.  
  1871. &lt;p&gt;This is great news and rather unexpected. Time to hit up &lt;a href=&quot;http://www.asp.net&quot;&gt;www.asp.net&lt;/a&gt; and F5 F5 F5...! &lt;/p&gt;
  1872.  
  1873. &lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; As everyone is aware by now, I&amp;#39;m sure, the MVC Framework has been released. You can &lt;a href=&quot;http://asp.net/downloads/3.5-extensions/&quot;&gt;get it here&lt;/a&gt;.&lt;/p&gt;
  1874. </content>
  1875. </entry>
  1876. <entry>
  1877.   <title>MVC Framework Delayed</title>
  1878.   <link href="http://www.squaredroot.com/2007/12/07/mvc-framework-delayed/"/>
  1879.   <updated>2007-12-07T00:00:00+00:00</updated>
  1880.   <id>http://www.squaredroot.com/2007/12/07/mvc-framework-delayed</id>
  1881.   <content type="html">&lt;p&gt;&lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2007/12/06/asp-net-mvc-framework-part-3-passing-viewdata-from-controllers-to-views.aspx#5419863&quot;&gt;ScottGu has posted a comment&lt;/a&gt; on his latest blog post saying that a last minute bug has delayed the release of the new .Net MVC Framework, which was previously slated for release today in the form of a CTP. From the sound of things we are now looking at a Monday release if further testing does not reveal any further issues. &lt;/p&gt;
  1882.  
  1883. &lt;p&gt;I&amp;#39;m sure I speak for almost all of us that are awaiting this highly anticipated release when I say that all of their hard work is appreciated and while the delay is disappointing, what is a few more days? The full text of Scott&amp;#39;s comment is below: &lt;/p&gt;
  1884.  
  1885. &lt;blockquote&gt;
  1886.  
  1887. Quick update to everyone - we found a last minute bug late last night, and had to-do a rebuild of the bits. This unfortunately means we won&#39;t go live today as originally planned. The team is working hard, though, to try and get it out ASAP (they will be here this weekend finishing the test pass).
  1888.  
  1889. I&#39;ll do a blog post announcing it as soon as it is live. As penance I&#39;m also doing a long Part 4 blog post this weekend that covers editing and form posting scenarios, which combined with the first three tutorial posts should provide a pretty good foundation for working with the bits.
  1890.  
  1891. Many apologies for the delay - almost there now though,
  1892.  
  1893. Scott
  1894. &lt;/blockquote&gt;
  1895. </content>
  1896. </entry>
  1897. <entry>
  1898.   <title>BlogEngine.net 1.2.5 Scrapped</title>
  1899.   <link href="http://www.squaredroot.com/2007/12/07/blogenginenet-125-scrapped/"/>
  1900.   <updated>2007-12-07T00:00:00+00:00</updated>
  1901.   <id>http://www.squaredroot.com/2007/12/07/blogenginenet-125-scrapped</id>
  1902.   <content type="html">&lt;p&gt;Apparently this just isn&amp;#39;t my day when it comes to project released that I&amp;#39;ve been looking forward to. &lt;a href=&quot;http://blog.madskristensen.dk/&quot;&gt;Mads Kristensen&lt;/a&gt; posted to the &lt;a href=&quot;http://dotnetblogengine.net/&quot;&gt;BlogEngine.net project&amp;#39;s website&lt;/a&gt; stating that &lt;a href=&quot;http://dotnetblogengine.net/post/Release-news.aspx&quot;&gt;the 1.2.5 release of the project (a service pack, really) will no longer happen&lt;/a&gt; and that all of its changes will be rolled into a 1.3 release, due before the end of the year. &lt;/p&gt;
  1903.  
  1904. &lt;p&gt;Disappointing, yes, but really for the best. The 1.2.5 release fixed quite a few bugs, but none of them show stoppers (well, for me) and 1.3 looks to add some new features to the equation. &lt;/p&gt;
  1905.  
  1906. &lt;h2&gt;Coming in 1.3:&lt;/h2&gt;
  1907.  
  1908. &lt;ul&gt;
  1909. &lt;li&gt;Full mono support (right out of the box)&lt;/li&gt;
  1910. &lt;li&gt;Updated Meta-Weblog API including support for creating/editing pages in WLW&lt;/li&gt;
  1911. &lt;li&gt;Improved Blog importer/exporter, including support for easily switching between XML and SQL backends &lt;/li&gt;
  1912. &lt;li&gt;New extension manager to managing extensions and their settings&lt;/li&gt;
  1913. &lt;li&gt;New events for extension writers&lt;/li&gt;
  1914. &lt;li&gt;Support for mobile devices&lt;/li&gt;
  1915. &lt;li&gt;New themes&lt;/li&gt;
  1916. &lt;/ul&gt;
  1917.  
  1918. &lt;p&gt;I&amp;#39;m especially looking forward to the mobile device support and further Live Writer integration. &lt;/p&gt;
  1919. </content>
  1920. </entry>
  1921. <entry>
  1922.   <title>GraffitiCMS Beta Opens</title>
  1923.   <link href="http://www.squaredroot.com/2007/12/05/graffiticms-beta-opens/"/>
  1924.   <updated>2007-12-05T00:00:00+00:00</updated>
  1925.   <id>http://www.squaredroot.com/2007/12/05/graffiticms-beta-opens</id>
  1926.   <content type="html">&lt;p class=&quot;warning&quot;&gt;GraffitiCMS appears to be effectively dead now, and has been released to the community. You can still &lt;a href=&quot;http://graffiticms.codeplex.com/&quot;&gt;find the code on CodePlex.&lt;/a&gt;&lt;/p&gt;
  1927.  
  1928. &lt;p&gt;&lt;a href=&quot;http://graffiticms.com/&quot;&gt;GraffitiCMS&lt;/a&gt; (from &lt;a href=&quot;http://telligent.com/&quot;&gt;Telligent&lt;/a&gt;, makers of &lt;a href=&quot;http://communityserver.org&quot;&gt;Community Server&lt;/a&gt;) has been released in beta. Head on over to their &lt;a href=&quot;http://graffiticms.com/&quot;&gt;official site&lt;/a&gt; to download it. &lt;/p&gt;
  1929. </content>
  1930. </entry>
  1931. <entry>
  1932.   <title>Add/Update/Delete with LINQPad</title>
  1933.   <link href="http://www.squaredroot.com/2007/12/05/addupdatedelete-with-linqpad/"/>
  1934.   <updated>2007-12-05T00:00:00+00:00</updated>
  1935.   <id>http://www.squaredroot.com/2007/12/05/addupdatedelete-with-linqpad</id>
  1936.   <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.dannydouglass.com&quot;&gt;Danny Douglass&lt;/a&gt; recently &lt;a href=&quot;http://www.dannydouglass.com/post/2007/12/LINQ-Editor-and-Quiz.aspx&quot;&gt;posted&lt;/a&gt; about &lt;a href=&quot;http://www.linqpad.net&quot;&gt;LINQPad&lt;/a&gt;, a query tool that understands LINQ. I spent some time today using it and am very impressed. It did take a while, however, to look through the numerous sample scripts and figure out exactly how to insert/update/delete data, so I thought I would share what I&amp;#39;ve found. The biggest changes between working in LINQ-To-SQL in a Visual Studio 2008 project and writing a LINQ query in LINQPad are the lack of a &lt;strong&gt;DataContext, *&lt;em&gt;the difference between *&lt;/em&gt;C# Expressions&lt;/strong&gt; and &lt;strong&gt;C# Statements&lt;/strong&gt;, and the addition of a &lt;strong&gt;Dump&lt;/strong&gt; command. &lt;/p&gt;
  1937.  
  1938. &lt;p&gt;&lt;strong&gt;No Data Context:&lt;/strong&gt; When you need to interact with a database via LINQ in a Visual Studio 2008 project, you do so by creating a LINQ-To-SQL DBML file that generates a data context for you. This data context is in charge of maintaining your database connection and is what you use to submit changes to the database. Because there is no data context readily available to you (and no .dbml file) in LINQPad, the way you go about this is slightly different. There is a globally-scoped subroutine, &amp;quot;SubmitChanges(),&amp;quot; that should be called whenever you wish to commit an action to the database. &lt;/p&gt;
  1939.  
  1940. &lt;p&gt;&lt;strong&gt;C# Expressions vs. C# Statements:&lt;/strong&gt; By default LINQPad opens in &amp;quot;C# Expression&amp;quot; mode. In this mode you can type a simple query like &amp;quot;from r in Regions select r&amp;quot; and run it to see the results. As far as I can tell there is no way to insert/update/delete data in this mode. By switching to &amp;quot;C# Statement(s)&amp;quot; mode you are able to declare variables, control flow statements, and reference objects; this is the mode you need to be in to insert/update/delete data. To enter &amp;quot;C# Statement(s)&amp;quot; mode, select it from the &amp;quot;Type&amp;quot; drop-down box at the top of the window as show below: &lt;/p&gt;
  1941.  
  1942. &lt;p&gt;&lt;img src=&quot;/custom/files/old/LINQPad_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1943.  
  1944. &lt;p&gt;&lt;strong&gt;object.Dump():&lt;/strong&gt; When you write a query in &amp;quot;C# Expression&amp;quot; mode the result of that query is automatically rendered to the Results frame (shown below). Because &amp;quot;C# Statement(s)&amp;quot; mode gives you the capability to run many queries in one execute, displaying the results of those queries must be manually invoked. To do so simply call the &amp;quot;.Dump()&amp;quot; method on the resultset of the query you want to display. &amp;quot;.Dump()&amp;quot; is implemented as an extension method available on all objects, so whether you are retrieving a single object, a list of objects, or an anonymous type the Dump method will be available to display your data. &lt;/p&gt;
  1945.  
  1946. &lt;p&gt;&lt;img src=&quot;/custom/files/old/LINQPad-Results_2.jpg&quot; alt=&quot;IMAGE&quot;&gt;&lt;/p&gt;
  1947.  
  1948. &lt;p&gt;Below I have included examples of several ways to query data, as well as an example each for inserting, updating, and deleting data. &lt;/p&gt;
  1949.  
  1950. &lt;script src=&quot;https://gist.github.com/3998228.js&quot;&gt; &lt;/script&gt;
  1951. </content>
  1952. </entry>
  1953. <entry>
  1954.   <title>CssHandler: CSS + Variables</title>
  1955.   <link href="http://www.squaredroot.com/2007/11/16/csshandler-first-release/"/>
  1956.   <updated>2007-11-16T00:00:00+00:00</updated>
  1957.   <id>http://www.squaredroot.com/2007/11/16/csshandler-first-release</id>
  1958.   <content type="html">&lt;p class=&quot;warning&quot;&gt;Please don&#39;t consider using this project anymore - it is old and out of date. &lt;a href=&quot;http://www.hanselman.com/blog/CoffeeScriptSassAndLESSSupportForVisualStudioAndASPNETWithTheMindscapeWebWorkbench.aspx&quot;&gt;Use something like SASS or LESS instead.&lt;/a&gt;&lt;/p&gt;
  1959.  
  1960. &lt;p&gt;It&amp;#39;s been more than three and a half years since &lt;a href=&quot;http://www.neopoleon.com&quot;&gt;Rory Blyth&lt;/a&gt; said &lt;a href=&quot;http://www.neopoleon.com/home/blogs/neo/archive/2004/03/06/8705.aspx&quot;&gt;&amp;quot;screw standards - let&amp;#39;s add variable support to CSS right this minute.&amp;quot;&lt;/a&gt; In retrospect, adding variables to CSS seems obvious; &lt;a href=&quot;http://www.google.com/search?q=css+variables&quot;&gt;everyone is asking about it&lt;/a&gt;. There have even been &lt;a href=&quot;http://www.codeproject.com/useritems/CSSVariables.asp&quot;&gt;one&lt;/a&gt; or &lt;a href=&quot;http://aspnetresources.com/articles/variables_in_css.aspx&quot;&gt;two&lt;/a&gt; other .Net solutions developed, though Rory&amp;#39;s solution has remained my favorite. With CSS2 barely working and &lt;a href=&quot;http://www.w3.org/Style/CSS/current-work&quot;&gt;CSS3 not addressing the issue&lt;/a&gt;, those of us who are tired of repeating ourselves throughout our CSS files have no choice but to take matters into our own hands.&lt;/p&gt;
  1961.  
  1962. &lt;p&gt;With that in mind I set out to update Rory&amp;#39;s code. Not that there was anything wrong with it in the first place, of course (this is where I try to tactfully avoid being drawn as a jerkasaurus in one of Rory&amp;#39;s comics), but Rory did whip the code up for a &lt;a href=&quot;http://www.padnug.org/&quot;&gt;PADNUG&lt;/a&gt; meeting and that &lt;em&gt;was&lt;/em&gt; about 3.5 million years ago (give or take many orders of magnitude). It was time to bring the CssHandler into 2007! Conveniently right before 2008.&lt;/p&gt;
  1963.  
  1964. &lt;p&gt;Lo and behold, someone else had beat me to it. &lt;a href=&quot;http://codingpatterns.blogspot.com/&quot;&gt;Gabe Moothart&lt;/a&gt; had already &lt;a href=&quot;http://www.codeplex.com/CssHandler/&quot;&gt;uploaded the CssHandler to CodePlex&lt;/a&gt;, and even improved upon it. While Rory&amp;#39;s code originally only allowed variable declarations &amp;amp; references and stripped comments, Gabe&amp;#39;s version also resolved application-relative paths (e.g.: &amp;quot;~/blah/blah.gif&amp;quot;) into browser friendly paths. I had further goals in mind though, and Gabe was kind enough to add me onto the project.&lt;/p&gt;
  1965.  
  1966. &lt;p&gt;With my updates complete, I am now proud to present...&lt;/p&gt;
  1967.  
  1968. &lt;h2&gt;CssHandler 1.0&lt;/h2&gt;
  1969.  
  1970. &lt;p&gt;&lt;em&gt;Features&lt;/em&gt;:&lt;/p&gt;
  1971.  
  1972. &lt;ul&gt;
  1973. &lt;li&gt;Define variables for later reference.&lt;/li&gt;
  1974. &lt;li&gt;Resolve application relative paths.&lt;/li&gt;
  1975. &lt;li&gt;Only link to one CSS file from your HTML page. Let the CssHandler combine additional CSS files at runtime to limit HTTP connections and share variable definitions across files.&lt;/li&gt;
  1976. &lt;li&gt;All comments are stripped before render.&lt;/li&gt;
  1977. &lt;li&gt;Most white-space is stripped before render.&lt;/li&gt;
  1978. &lt;li&gt;HttpHandler can be mapped to &amp;#39;*.css&amp;#39; or can be referenced as CssHandler.axd and passed a CSS file in the query string.&lt;/li&gt;
  1979. &lt;/ul&gt;
  1980.  
  1981. &lt;p&gt;&lt;em&gt;Bugs fixed:&lt;/em&gt;&lt;/p&gt;
  1982.  
  1983. &lt;ul&gt;
  1984. &lt;li&gt;The @define{...} block is no longer sent down to the client.&lt;/li&gt;
  1985. &lt;li&gt;Similarly named variables no longer present a problem.&lt;/li&gt;
  1986. &lt;/ul&gt;
  1987.  
  1988. &lt;p&gt;&lt;em&gt;Example:&lt;/em&gt;&lt;/p&gt;
  1989.  
  1990. &lt;p&gt;The HTML references &amp;quot;styles.css&amp;quot;, which looks like:&lt;/p&gt;
  1991.  
  1992. &lt;script src=&quot;https://gist.github.com/3998144.js?file=styles.css&quot;&gt; &lt;/script&gt;
  1993.  
  1994. &lt;p&gt;As seen above, &amp;quot;styles.css&amp;quot; references &amp;quot;styles2.css&amp;quot; via the @import statement, which looks like:&lt;/p&gt;
  1995.  
  1996. &lt;script src=&quot;https://gist.github.com/3998144.js?file=styles2.css&quot;&gt; &lt;/script&gt;
  1997.  
  1998. &lt;p&gt;The CssHandler then:&lt;/p&gt;
  1999.  
  2000. &lt;ol&gt;
  2001. &lt;li&gt;Intercepts the browser&amp;#39;s request for &amp;quot;styles.css&amp;quot;.&lt;/li&gt;
  2002. &lt;li&gt;Resolves the two URLs that are using application relative paths.&lt;/li&gt;
  2003. &lt;li&gt;Replaces the @import directive with the text from &amp;quot;styles2.css&amp;quot;.&lt;/li&gt;
  2004. &lt;li&gt;Strips all comments from the CSS.&lt;/li&gt;&lt;/li&gt;
  2005. &lt;li&gt;Replaces all referenced variables with their defined values.&lt;/li&gt;
  2006. &lt;li&gt;Compresses most of the CSS&amp;#39;s white-space.&lt;/li&gt;
  2007. &lt;li&gt;Renders the following to the browser:&lt;/li&gt;
  2008. &lt;/ol&gt;
  2009.  
  2010. &lt;script src=&quot;https://gist.github.com/3998144.js?file=styles_rendered.css&quot;&gt; &lt;/script&gt;
  2011.  
  2012. &lt;p&gt;I hope you find it as useful as I have. Many thanks to Rory Blyth and Gabe Moothart. Hopefully CSS4 will add variables and we&amp;#39;ll never have to use this again!&lt;/p&gt;
  2013.  
  2014. &lt;p&gt;&lt;a href=&quot;http://www.codeplex.com/CssHandler/&quot;&gt;Visit the project&amp;#39;s CodePlex site to download&lt;/a&gt;.&lt;/p&gt;
  2015.  
  2016. &lt;p&gt;&lt;strong&gt;Update (Dec. 2, 2007):&lt;/strong&gt; Rory has posted and &lt;a href=&quot;http://www.neopoleon.com/home/blogs/neo/archive/2007/11/23/28201.aspx&quot;&gt;given his blessing&lt;/a&gt;, so to speak. Thanks Rory!&lt;/p&gt;
  2017. </content>
  2018. </entry>
  2019.  
  2020. </feed>
  2021.  

If you would like to create a banner that links to this page (i.e. this validation result), do the following:

  1. Download the "valid Atom 1.0" banner.

  2. Upload the image to your own server. (This step is important. Please do not link directly to the image on this server.)

  3. Add this HTML to your page (change the image src attribute if necessary):

If you would like to create a text link instead, here is the URL you can use:

http://www.feedvalidator.org/check.cgi?url=http%3A//feeds2.feedburner.com/SquaredRoot/

Copyright © 2002-9 Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda