<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Dan Maharry</title>
    <description>Dan Maharry is a UK-based ASP.NET &amp; C# developer, writer and reviewer. He also makes music &amp; films.</description>
    <link>http://blog.hmobius.com/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.6.0.0</generator>
    <language>en-GB</language>
    <blogChannel:blogRoll>http://blog.hmobius.com/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.dotnetblogengine.net/syndication.axd</blogChannel:blink>
    <dc:creator>Dan Maharry</dc:creator>
    <dc:title>Dan Maharry</dc:title>
    <geo:lat>51.979700</geo:lat>
    <geo:long>-1.327600</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/DansArchive" /><feedburner:info uri="dansarchive" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>51.9797</geo:lat><geo:long>-1.3276</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/2.0/</creativeCommons:license><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site, subject to copyright and fair use.</feedburner:browserFriendly><item>
      <title>ASP.NET 4.0 Part 12, Routing Helper Functions</title>
      <description>&lt;p&gt;Welcome to part 12 of &lt;a href="http://blog.hmobius.com/post/2010/02/09/ASPNET-40-Cometh.aspx"&gt;my tour through ASP.NET 4.0&lt;/a&gt;. In the &lt;a href="http://blog.hmobius.com/post/2010/03/10/ASPNET-40-Part-11-Configuring-Routing-Is-Easier.aspx"&gt;last episode&lt;/a&gt;, we saw how improvements in ASP.NET 4.0 have made it much simpler to get routing for webforms set up and working. In this one, we’ll look in more detail at the new routing-friendly classes, properties and methods you can start to use once routing is set up.&lt;/p&gt;  &lt;h2&gt;Defining Routes&lt;/h2&gt;  &lt;p&gt;Let’s start by defining a couple of routes and using them as examples throughout this post. &lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;routes.MapPageRoute(&amp;quot;Users&amp;quot;, &amp;quot;user-{username}&amp;quot;, &amp;quot;~/users.aspx&amp;quot;);
routes.MapPageRoute(&amp;quot;Forums&amp;quot;, &amp;quot;forum-{forumname}&amp;quot;, &amp;quot;~/forum.aspx&amp;quot;);
routes.MapPageRoute(&amp;quot;Threads&amp;quot;, &amp;quot;forum-{forumname}/thread-{threadid}&amp;quot;, &amp;quot;~/thread.aspx&amp;quot;);&lt;/pre&gt;

&lt;p&gt;We'll also create another one with default values for each of the route parameters, using another of MapPageRoute's overloads.&lt;/p&gt;

&lt;pre class="brush: csharp; auto-links: false;"&gt;routes.MapPageRoute(&amp;quot;Posts&amp;quot;, &amp;quot;post/{forumname}/{threadid}/{postid}&amp;quot;, 
  &amp;quot;~/thread.aspx&amp;quot;, false,
  new RouteValueDictionary { 
    { &amp;quot;forumname&amp;quot;, &amp;quot;Fishing&amp;quot; }, { &amp;quot;threadid&amp;quot;, &amp;quot;12&amp;quot; }, { &amp;quot;postid&amp;quot;, &amp;quot;1&amp;quot; } 
  });&lt;/pre&gt;

&lt;p&gt;Should we now visit ~/post/, thread.aspx will load and be passed in &amp;quot;Fishing&amp;quot;, &amp;quot;12&amp;quot; and &amp;quot;1&amp;quot; as the values for the forumname, threadid and postid route parameters respectively. Should we visit ~/post/art, the default values for the threadid and postid parameters will passed in along with &amp;quot;art&amp;quot; as the forumname.&lt;/p&gt;

&lt;p&gt;MapPageRoute has a couple of other tricks up its sleeve as well. An overload with five parameters allows you to define a basic validation for legal values for each of the route parameters. For example, let's say we wanted forumname to contain only lower-case letters. Then we would define the route like this.&lt;/p&gt;

&lt;pre class="brush: csharp; auto-links: false;"&gt;routes.MapPageRoute(&amp;quot;Posts&amp;quot;, &amp;quot;post/{forumname}/{threadid}/{postid}&amp;quot;, 
  &amp;quot;~/thread.aspx&amp;quot;, false,
  new RouteValueDictionary { 
    { &amp;quot;forumname&amp;quot;, &amp;quot;Fishing&amp;quot; }, { &amp;quot;threadid&amp;quot;, &amp;quot;12&amp;quot; }, { &amp;quot;postid&amp;quot;, &amp;quot;1&amp;quot; } 
  },
  new RouteValueDictionary { { &amp;quot;forumname&amp;quot;, &amp;quot;^[a-z]*$&amp;quot; } }
);&lt;/pre&gt;

&lt;p&gt;Don't forget as well that MapPageRoute is just a quick route to registering a route that is handled by the built-in PageRouteHandler class. If you want to handle the request using your own handler, you can make the equivalent call to routes.Add.&lt;/p&gt;

&lt;pre class="brush: csharp; auto-links: false;"&gt;routes.Add(&amp;quot;Posts&amp;quot;,
  new Route(&amp;quot;post/{forumname}/{threadid}/{postid}&amp;quot;,
    new RouteValueDictionary { 
      { &amp;quot;forumname&amp;quot;, &amp;quot;Fishing&amp;quot; }, { &amp;quot;threadid&amp;quot;, &amp;quot;12&amp;quot; }, { &amp;quot;postid&amp;quot;, &amp;quot;1&amp;quot; } },
    new RouteValueDictionary { { &amp;quot;forumname&amp;quot;, &amp;quot;^[a-z]*$&amp;quot; } }, null,
    new PageRouteHandler(&amp;quot;~/thread.aspx&amp;quot;, false)));&lt;/pre&gt;

&lt;h2&gt;Hyperlinks&lt;/h2&gt;

&lt;p&gt;With our routes defined, we can now set up hyperlinks between routes. All we need are the name of the route and the values of any route parameters. If we need to do it inline in the code (perhaps because it's part of a databinding operation) we can use the new &amp;lt;%$RouteUrl %&amp;gt; syntax. For example.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;Go to &amp;lt;a runat=&amp;quot;server&amp;quot; 
  href='&amp;lt;%$RouteUrl:RouteName=Users, UserName=Dan  %&amp;gt;'&amp;gt;dan's page&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;
Go to &amp;lt;a runat=&amp;quot;server&amp;quot; 
  href='&amp;lt;%$RouteUrl:RouteName=Forums, ForumName=Coding  %&amp;gt;'&amp;gt;coding forum&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;
Go to &amp;lt;a runat=&amp;quot;server&amp;quot; 
  href='&amp;lt;%$RouteUrl:RouteName=Posts %&amp;gt;'&amp;gt;the default post&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&lt;/pre&gt;

&lt;p&gt;If we need to set the hyperlink in code-behind, it's easiest to use GetRouteUrl(), a new method on System.Web.UI.Control and therefore the Page class. (This actually calls RouteCollection.GetVirtualPath() to get the required URL if you'd prefer to use that instead).&lt;/p&gt;

&lt;p&gt;GetRouteUrl() has four overloads, broadly taking the following form&lt;/p&gt;

&lt;pre class="brush: csharp; auto-links: false;"&gt;GetRouteUrl([string routeName], routeParameters);&lt;/pre&gt;

&lt;p&gt;Where specifying the routeName is optional and the routeParameters can be added as either an object of anonymous type or as a RouteValueDictionary. For example,&lt;/p&gt;

&lt;pre class="brush: csharp; auto-links: false;"&gt;// Named route, parameters in anonymous type object
hypUsers.NavigateUrl = Page.GetRouteUrl(&amp;quot;users&amp;quot;, new {username = &amp;quot;Dan&amp;quot; });

// Named route, parameters in RouteValueDictionary
hypForums.NavigateUrl = Page.GetRouteUrl(&amp;quot;forums&amp;quot;, 
  new RouteValueDictionary { { &amp;quot;forumname&amp;quot;, &amp;quot;Fishing&amp;quot; } );

// Named route, no parameters set, so defaults used
hypPosts.NavigateUrl = Page.GetRouteUrl(&amp;quot;posts&amp;quot;, new {} );

// No route named
hypNoName.NavigateUrl = Page.GetRouteUrl(new { forumname = &amp;quot;Gaming&amp;quot; });&lt;/pre&gt;

&lt;p&gt;In the last example here, we've not named a route to use a basis for a URL, but we have specified a route parameter called forumname, which appears in three of our declared routes. Which route will it use as a basis to generate the URL? Simply, the first route defined that contains the named parameter. In this case, that's &amp;quot;forums&amp;quot;.&lt;/p&gt;

&lt;h2&gt;Redirection&lt;/h2&gt;

&lt;p&gt;If you need to redirect a user's browser to a given address, you'll need to call one of the three new redirect methods we mentioned briefly in &lt;a href="http://blog.hmobius.com/post/2010/03/04/ASPNET-40-Part-10-A-Handful-Of-Little-Things.aspx" target="_blank"&gt;part 10&lt;/a&gt;: either Response.RedirectToRoute() or Response.RedirectToRoutePermanent(). Both have the same five overloads with the only difference that RedirectToRoute() sends an HTTP 302 temporary redirect to the browser and RedirectToRoutePermanent() sends a HTTP 301. &lt;/p&gt;

&lt;pre class="brush: csharp; auto-links: false;"&gt;// No Route Named, Parameters In Anonymous Type object
Response.RedirectToRoute( new { username = &amp;quot;Dan&amp;quot; });

// No Route Named, Parameters In RouteValueDictionary
Response.RedirectToRoute( 
  new RouteValueDictionary { { &amp;quot;forumname&amp;quot;, &amp;quot;Fishing&amp;quot; } ););

// Only route named, so default parameter values used
Response.RedirectToRoute(&amp;quot;posts&amp;quot;); 

// Named route, parameters in anonymous type object
Response.RedirectToRoute(&amp;quot;users&amp;quot;, new {username = &amp;quot;Dan&amp;quot; });

// Named route, parameters in RouteValueDictionary
Response.RedirectToRoute(&amp;quot;forums&amp;quot;, 
  new RouteValueDictionary { { &amp;quot;forumname&amp;quot;, &amp;quot;Fishing&amp;quot; } );&lt;/pre&gt;

&lt;p&gt;Note that both these methods are equivalent to calling &lt;a href="http://msdn.microsoft.com/en-us/library/a8wa7sdt(v=VS.100).aspx" target="_blank"&gt;Response.Redirect(url, stopProcessing)&lt;/a&gt; with stopProcessing set to false. Again, more on that &lt;a href="http://blog.hmobius.com/post/2010/03/04/ASPNET-40-Part-10-A-Handful-Of-Little-Things.aspx" target="_blank"&gt;here in part 10&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;RouteParameters&lt;/h2&gt;

&lt;p&gt;Last but not least, DataSource users will be interested to know that Microsoft have added a new RouteParameter object to ASP.NET 4.0 which you can use in exactly the same way as, for instance, a QueryStringParameter or a ControlParameter. If you use the Configure DataSource wizard you'll see it added to the bottom of the Source list when you need to add a WHERE clause to the data source.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.hmobius.com/image.axd?picture=1_RouteParameter.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="1_RouteParameter" border="0" alt="1_RouteParameter" src="http://blog.hmobius.com/image.axd?picture=1_RouteParameter_thumb.png" width="640" height="456" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you do select Route from the Source list, you'll need to set the name of the route parameter you want to use and also give a default value for the parameter if it isn't available for some reason.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.hmobius.com/image.axd?picture=2_RouteParameter.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="2_RouteParameter" border="0" alt="2_RouteParameter" src="http://blog.hmobius.com/image.axd?picture=2_RouteParameter_thumb.png" width="640" height="456" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are the only differences between using a RouteParameter and any other parameter object you use with your DataSources. If you prefer to write the code yourself, the net result of the screesnshots above is the following markup.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;asp:SqlDataSource ID=&amp;quot;SqlDataSource1&amp;quot; runat=&amp;quot;server&amp;quot; 
  ConnectionString=&amp;quot;&amp;lt;%$ ConnectionStrings:UsersDB %&amp;gt;&amp;quot; 
  SelectCommand=&amp;quot;SELECT [UserId], [Username] FROM [Users] WHERE ([Username] = @Username)&amp;quot;&amp;gt;
  &amp;lt;SelectParameters&amp;gt;
    &amp;lt;asp:RouteParameter DefaultValue=&amp;quot;Dan&amp;quot; Name=&amp;quot;Username&amp;quot; RouteKey=&amp;quot;username&amp;quot; 
         Type=&amp;quot;String&amp;quot; /&amp;gt;
  &amp;lt;/SelectParameters&amp;gt;
&amp;lt;/asp:SqlDataSource&amp;gt;&lt;/pre&gt;

&lt;p&gt;So then, in this article, we've looked at the new methods and objects you'll likely use most often when working with webforms and routing. Until the next time, happy coding.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=OFk3tKjUM3I:T7EQQq6Y8Ow:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=OFk3tKjUM3I:T7EQQq6Y8Ow:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=OFk3tKjUM3I:T7EQQq6Y8Ow:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=OFk3tKjUM3I:T7EQQq6Y8Ow:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=OFk3tKjUM3I:T7EQQq6Y8Ow:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=OFk3tKjUM3I:T7EQQq6Y8Ow:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=OFk3tKjUM3I:T7EQQq6Y8Ow:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=OFk3tKjUM3I:T7EQQq6Y8Ow:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/OFk3tKjUM3I" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/OFk3tKjUM3I/post.aspx</link>
      <author>DanM</author>
      <comments>http://blog.hmobius.com/post/2010/03/14/ASPNET-40-Part-12-Routing-Helper-Functions.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=a39de99f-cf14-4881-a624-7cd4c37ce416</guid>
      <pubDate>Sun, 14 Mar 2010 21:00:00 +0000</pubDate>
      <category>Geek Stuff</category>
      <category>ASP.NET</category>
      <dc:publisher>DanM</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=a39de99f-cf14-4881-a624-7cd4c37ce416</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=a39de99f-cf14-4881-a624-7cd4c37ce416</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/14/ASPNET-40-Part-12-Routing-Helper-Functions.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=a39de99f-cf14-4881-a624-7cd4c37ce416</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=a39de99f-cf14-4881-a624-7cd4c37ce416</feedburner:origLink></item>
    <item>
      <title>Today's Bookmarks (Mar 13 2010)</title>
      <description>&lt;ul class="delicious"&gt;&lt;li&gt;
                &lt;div class="delicious-link"&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2010/03/10/fluentpath-a-fluent-wrapper-around-system-io.aspx"&gt;FluentPath: a fluent wrapper around System.IO&lt;/a&gt;&lt;/div&gt;
                &lt;div class="delicious-extended"&gt;Bertrand LeRoy presents an LINQ-based fluent API style around Path.&lt;/div&gt;
                &lt;div class="delicious-tags"&gt;(tags: &lt;a href="http://delicious.com/hmobius/c%23" rel="tag"&gt;c#&lt;/a&gt; &lt;a href="http://delicious.com/hmobius/.net35" rel="tag"&gt;.net35&lt;/a&gt; &lt;a href="http://delicious.com/hmobius/linq" rel="tag"&gt;linq&lt;/a&gt;)&lt;/div&gt;
            &lt;/li&gt;&lt;li&gt;
                &lt;div class="delicious-link"&gt;&lt;a href="http://blogs.iis.net/ruslany/archive/2010/03/11/iis-url-rewrite-2-0-release-to-web.aspx"&gt;IIS URL Rewrite 2.0&lt;/a&gt;&lt;/div&gt;
                &lt;div class="delicious-extended"&gt;Details and release notes for v2 of the IIS URL Rewrite module and accompanying samples&lt;/div&gt;
                &lt;div class="delicious-tags"&gt;(tags: &lt;a href="http://delicious.com/hmobius/iis7" rel="tag"&gt;iis7&lt;/a&gt;)&lt;/div&gt;
            &lt;/li&gt;&lt;/ul&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CT6i30VgKdo:9ORIgr7Lf38:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CT6i30VgKdo:9ORIgr7Lf38:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CT6i30VgKdo:9ORIgr7Lf38:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=CT6i30VgKdo:9ORIgr7Lf38:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CT6i30VgKdo:9ORIgr7Lf38:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=CT6i30VgKdo:9ORIgr7Lf38:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CT6i30VgKdo:9ORIgr7Lf38:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=CT6i30VgKdo:9ORIgr7Lf38:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/CT6i30VgKdo" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/CT6i30VgKdo/post.aspx</link>
      <author>Dan@Delicious</author>
      <comments>http://blog.hmobius.com/post/2010/03/13/links-for-2010-03-12.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=d07e3c05-1357-41eb-8e30-e3c3551c0a0d</guid>
      <pubDate>Sat, 13 Mar 2010 05:02:00 +0000</pubDate>
      <category>Bookmarks</category>
      <dc:publisher>Dan@Delicious</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=d07e3c05-1357-41eb-8e30-e3c3551c0a0d</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=d07e3c05-1357-41eb-8e30-e3c3551c0a0d</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/13/links-for-2010-03-12.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=d07e3c05-1357-41eb-8e30-e3c3551c0a0d</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=d07e3c05-1357-41eb-8e30-e3c3551c0a0d</feedburner:origLink></item>
    <item>
      <title>Today's Bookmarks (Mar 11 2010)</title>
      <description>&lt;ul class="delicious"&gt;
&lt;li&gt;
&lt;div class="delicious-link"&gt;&lt;a href="http://www.4guysfromrolla.com/articles/030310-1.aspx"&gt;Improving CSS With .LESS&lt;/a&gt;&lt;/div&gt;
&lt;div class="delicious-extended"&gt;Scott Mitchell investigates how using .LESS (a port of the Ruby LESS library) makes using CSS that bit easier.&lt;/div&gt;
&lt;div class="delicious-tags"&gt;(tags: &lt;a href="http://delicious.com/hmobius/css"&gt;css&lt;/a&gt; &lt;a href="http://delicious.com/hmobius/asp.net"&gt;asp.net&lt;/a&gt; &lt;a href="http://delicious.com/hmobius/c%23"&gt;c#&lt;/a&gt; &lt;a href="http://delicious.com/hmobius/html"&gt;html&lt;/a&gt;)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=n6hrenViibk:Iyz0ZpQTNjU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=n6hrenViibk:Iyz0ZpQTNjU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=n6hrenViibk:Iyz0ZpQTNjU:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=n6hrenViibk:Iyz0ZpQTNjU:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=n6hrenViibk:Iyz0ZpQTNjU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=n6hrenViibk:Iyz0ZpQTNjU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=n6hrenViibk:Iyz0ZpQTNjU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=n6hrenViibk:Iyz0ZpQTNjU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/n6hrenViibk" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/n6hrenViibk/post.aspx</link>
      <author>Dan@Delicious</author>
      <comments>http://blog.hmobius.com/post/2010/03/11/links-for-2010-03-10.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=747de7dc-6183-4275-9958-6094e15851f9</guid>
      <pubDate>Thu, 11 Mar 2010 05:07:00 +0000</pubDate>
      <category>Bookmarks</category>
      <dc:publisher>Dan@Delicious</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=747de7dc-6183-4275-9958-6094e15851f9</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=747de7dc-6183-4275-9958-6094e15851f9</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/11/links-for-2010-03-10.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=747de7dc-6183-4275-9958-6094e15851f9</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=747de7dc-6183-4275-9958-6094e15851f9</feedburner:origLink></item>
    <item>
      <title>ASP.NET 4.0 Part 11, Configuring Routing Is Easier</title>
      <description>&lt;p&gt;Welcome to part 11 of &lt;a href="http://blog.hmobius.com/post/2010/02/09/ASPNET-40-Cometh.aspx"&gt;my tour through ASP.NET 4.0&lt;/a&gt;. In this episode, we're going to take a look at how routing for webforms has been made easier to set up in ASP.NET 4.0. This will be followed up in Part 12 with a look at the new route-aware classes, methods and properties in more detail.&lt;/p&gt;
&lt;p&gt;Routing was originally introduced in ASP.NET 3.5 SP1 as part of the foundations to enable the ASP.NET MVC template engine to work. It could also be used against the webforms engine but a certain amount of rolling-your-own-foundation coding was required to enable it properly.&lt;/p&gt;
&lt;p&gt;In ASP.NET 4.0, that initial legwork is no longer necessary as routing for webforms is now supported as standard in System.Web, the majority of the configuration for routing is pre-set in system-wide config files, and some extra goodness has been added into various classes for ease of use as well. All in all, if you haven't had occasion to try routing with webforms before, try it with ASP.NET 4.0. It's really simple.&lt;/p&gt;
&lt;h2&gt;Why?&lt;/h2&gt;
&lt;p&gt;There are a &lt;a title="Scott Mitchell on ASP.NET 4.0 Routing" href="http://www.4guysfromrolla.com/articles/012710-1.aspx" target="_blank"&gt;metric&lt;/a&gt; / &lt;a title="Scott Guthrie on ASP.NET 4.0 Routing" href="http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx" target="_blank"&gt;boatload&lt;/a&gt; / &lt;a title="Scott Galloway on ASP.NET 4.0 Routing" href="http://mostlylucid.net/archive/2009/01/25/asp.net-4.0-webform-routing-quick-rsquon-dirty-version.aspx" target="_blank"&gt;of articles&lt;/a&gt; introducing routing and how it works. In a nutshell, routing, like URL rewriting, is a response to two general criticisms of websites.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;We humans prefer it if a page's URL is readable. For example, &lt;em&gt;http://myforums.info/forum-Music&lt;/em&gt; is easier to read than &lt;em&gt;http://myforums.info/forum.aspx?id=2&lt;/em&gt;. It's easier to remember too &lt;/li&gt;
&lt;li&gt;Search engines prefer human-readable URLs as well. In particular, they like URLs with no querystring parameters at the end. And, the more search engine friendly a site's URLs are, the better indexed they may be by a search engine and the higher they may appear in search rankings. (Obviously, URLs aren't the only thing indexing robots look at when they come to your site - &lt;a title="New Page Directive Attributes" href="http://blog.hmobius.com/post/2010/02/22/ASPNET-40-Part-6-New-Page-Directive-Attributes.aspx" target="_blank"&gt;Descriptions and Keywords&lt;/a&gt; are up there with &lt;a title="Professional SEO with ASP.NET (Amazon UK link)" href="http://www.amazon.co.uk/exec/obidos/ASIN/0470131470/hmobiuscom-21" target="_blank"&gt;a host of other things&lt;/a&gt; too - but they certainly help.) &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So then, the major consequence of routing as far as webforms is concerned are URLs which are more readable for humans and search robots alike with &lt;em&gt;no reduction of information to the page itself&lt;/em&gt;.&lt;/p&gt;
&lt;h2&gt;How?&lt;/h2&gt;
&lt;p&gt;Routes are initialized as named, regular expressions (using a subset of the standard .NET RegEx syntax) and given an order in which they will be matched against the currently requested URL. For example,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;user-{username} &lt;/li&gt;
&lt;li&gt;forum-{forumname} &lt;/li&gt;
&lt;li&gt;forum-{forumname}/thread-{threadid} &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let's say a request comes to the server for http://myforums.info/forum-Music.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the request is for a page that actually exists on the site, no routing actually occurs and that page is loaded and runs as normal. &lt;/li&gt;
&lt;li&gt;If the page doesn't exist, the requested URL is matched against each initialized route in the order you've specified. In this example, user-{username} doesn't match the requested URL, so the next route is tried. &lt;/li&gt;
&lt;li&gt;When a route matching the requested URL is found, the request is routed to the page that deals with that route. Any named sections of the route are then made available to the handling page within the &lt;em&gt;RouteData&lt;/em&gt; collection. For example, http://myforums.info/forum-Music matches forum-{forumname}, so control for the request would be passed to the page for that route along with a RouteData collection containing one KeyValuePair where forumname is the Key and Music is its value. &lt;/li&gt;
&lt;li&gt;If no route is found to match the incoming request, it is passed to the standard ASP.NET 404 page or a custom page if you've defined one. &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Routing Is Neither URL Rewriting nor Redirection&lt;/h2&gt;
&lt;p&gt;Hopefully, the above description should differentiate routing from URL rewriting and page redirection. However, just in case it didn't...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Routing is not Page Redirection&lt;/em&gt; &lt;br /&gt;Redirection can only work if the incoming URL is for a page that exist. It works by sending a response to the browser saying that the page has moved with the browser then issuing a second request for the URL it is being redirected to. Routed URLs on the other hand do not necessarily refer to a page that actually exists - they will often seem to refer to directories for example - and are dealt with in one request. Browsers will not issue a second request for the actual page which handles the route. &lt;/li&gt;
&lt;li&gt;&lt;em&gt;Routing is not URL Rewriting        &lt;br /&gt;&lt;/em&gt;URL rewriting occurs very early on in the asp.net request pipeline, literally as request processing is beginning. When the rewritten URL is resolved, IIS then sends it down the pipeline to find a handler to deal with it. It has no control over what handler deals with the request. Routing, on the other hand, occurs further down the pipeline, once the request has been authorised, at which point the routing module dispatches the request to a handler based on which route the request matches and the handler specified by you to deal with the route. (IIS team member Ruslan Yarushev goes into &lt;a title="Article on the differences between URL Rewriting and Routing" href="http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/" target="_blank"&gt;much more detail on the differences between the two in this article&lt;/a&gt;.) &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Setting Up Webforms Routing In ASP.NET 3.5&lt;/h2&gt;
&lt;p&gt;Briefly, here are the steps needed to enable routing for webforms in ASP.NET 3.5.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;All routing classes and namespaces are found in a new DLL, System.Web.Routing.dll to be included as a reference in your website. &lt;/li&gt;
&lt;li&gt;The UrlRoutingModule needs to be added to the list of modules enabled for the site in web.config (&lt;a title="Setting up Webforms Routing v3.5 on MSDN" href="http://msdn.microsoft.com/en-us/library/cc668202.aspx" target="_blank"&gt;as described here in MSDN&lt;/a&gt;) &lt;/li&gt;
&lt;li&gt;A handler class inheriting IRouteHandler needs to be created that understands how to resolve the route into the page or handler that will actually process the request and generate the RouteData collection. Both &lt;a title="Phil Haack on Routing with Webforms" href="http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx" target="_blank"&gt;Phil Haack&lt;/a&gt; and &lt;a title="Chris Cavanagh on setting up webforms routing" href="http://chriscavanagh.wordpress.com/2008/03/11/aspnet-routing-goodbye-url-rewriting/" target="_blank"&gt;Chris Cavanagh&lt;/a&gt; put forward basic implementations of this handler, discussing potential security issues. &lt;/li&gt;
&lt;li&gt;Register the routes for the site in the Application_Start handler of global.asax using your new route handler class. For example, &lt;/li&gt;
&lt;/ol&gt;
&lt;pre class="brush: csharp; auto-links: false;"&gt;protected void Application_Start(object sender, EventArgs e)
{
 RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
 // Route existing files (default will shortcut routing if physical file exists)
 RouteTable.Routes.RouteExistingFiles = true;

 // Add StopRoutingHandler for .axd and .asmx requests
 routes.Add(new Route("{resource}.axd/{*pathInfo}", 
              new StopRoutingHandler()));
 routes.Add(new Route("{service}.asmx/{*pathInfo}", 
              new StopRoutingHandler()));

 // Add existing routes
 routes.Add("Users", new Route("user-{username}", 
              new WebFormRouteHandler("~/users.aspx", true)));
 routes.Add("Forums", new Route("forum-{forumname}", 
              new WebFormRouteHandler("~/forum.aspx", true)));
 routes.Add("Threads", new Route("forum-{forumname}/thread-{threadid}", 
              new WebFormRouteHandler("~/thread.aspx", true)));

 // Add an unnamed handler for all unknown requests (now created in the PageRoute table)
 //routes.Add(new Route("{value}", 
                new WebFormRouteHandler("~/pages/default.aspx")));
}&lt;/pre&gt;
&lt;ol start="5"&gt;
&lt;li&gt;Write your pages as you would normally using the RouteData collection in place of the Querystring class. You'll need to make RouteData available by passing a RequestContext object to the object that needs access to the RouteData. Again, &lt;a title="Phil Haack's IRouteableObject post" href="http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx" target="_blank"&gt;Phil Haack suggests one way of doing this (via an IRoutableObject interface) here&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;Finally, you have to configure IIS to have ASP.NET deal with requests to your routes, thus passing them on to your RouteHandler classes. If you're using IIS6 and your routes are extension-less (i.e. missing .aspx, .asmx , .ashx etc file extensions in their composition), you'll need to configure wildcard maps on a per-directory level according to where your routes point else you'll end up serving all your static files with ASP.NET as well. Full instructions for this come courtesy of Steve Sanderson (&lt;a href="http://blog.stevensanderson.com/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/" target="_blank"&gt;Part 1&lt;/a&gt;, &lt;a href="http://blog.stevensanderson.com/2008/07/07/overriding-iis6-wildcard-maps-on-individual-directories/" target="_blank"&gt;Part 2&lt;/a&gt;). &lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Setting Up Webforms Routing In ASP.NET 4.0&lt;/h2&gt;
&lt;p&gt;By comparison, the procedure is far more straightforward in ASP.NET 4.0, thanks in large part to Microsoft being able to open up and edit System.Web and the classes inside it. Let's compare&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;System.Web.Routing has been folded into System.Web.dll in .NET 4.0 so there is no need for an additional reference to it in your solution. &lt;/li&gt;
&lt;li&gt;The UrlRoutingModule is also already set up in the machine-wide web.config file which means that it works straight off the bat in IIS 6. For IIS 7 users, however, you'll need to enable it with the following addition to web.config. &lt;/li&gt;
&lt;/ol&gt;
&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;?xml version="1.0"?&amp;gt;
&amp;lt;configuration&amp;gt;
...
  &amp;lt;system.webServer&amp;gt;
    &amp;lt;modules runAllManagedModulesForAllRequests="true"&amp;gt;
      ...
    &amp;lt;/modules&amp;gt;
  &amp;lt;/system.webServer&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;ol start="3"&gt;
&lt;li&gt;ASP.NET 4.0 includes an implementation of IRouteHandler for you to use - it's called &lt;em&gt;PageRouteHandler&lt;/em&gt;. There's no reason why you can't build your own as before, but it's no longer necessary. &lt;/li&gt;
&lt;li&gt;You still need to register routes for your application but if you're using the built-in PageRouteHandler class, you can use the MapPageRoute helper method to make route registration clearer. &lt;/li&gt;
&lt;/ol&gt;
&lt;pre class="brush: csharp; auto-links: false;"&gt;protected void Application_Start(object sender, EventArgs e)
{
  RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
  // Route existing files (default will shortcut routing if physical file exists)
  RouteTable.Routes.RouteExistingFiles = true;

  // Add StopRoutingHandler for .axd and .asmx requests
  routes.Add(new Route("{resource}.axd/{*pathInfo}", 
              new StopRoutingHandler()));
  routes.Add(new Route("{service}.asmx/{*pathInfo}", 
              new StopRoutingHandler()));

  // Add existing routes with MapPageRoute helper method
  routes.MapPageRoute("Users", "user-{username}", "~/users.aspx");
  routes.MapPageRoute("Forums", "forum-{forumname}", "~/forum.aspx", true);

  // MapPageRoute is equivalent to adding a Route with the PageRouteHandler like so
  routes.Add("Threads", new Route("forum-{forumname}/thread-{threadid}", 
    new PageRouteHandler("~/thread.aspx", true)));
}&lt;/pre&gt;
&lt;ol start="5"&gt;
&lt;li&gt;Any pages you write now automatically have access to the RouteData collection as a property of the Page class itself, as well as several other route-aware additions we'll review in the next section. &lt;/li&gt;
&lt;/ol&gt;
&lt;pre class="brush: csharp; auto-links: false;"&gt;protected void Page_Load(object sender, EventArgs e)
{
  lblHello.Text = 
    RouteData.Values["username"] == null ?
      "Hello Mr A. Nonymous" : 
      String.Format("Hello {0}", RouteData.Values["username"].ToString());
}&lt;/pre&gt;
&lt;ol start="6"&gt;
&lt;li&gt;Regrettably, while integration into IIS7 Integrated Mode remains quite simple, you still need to configure IIS6 \ IIS7 in Classic mode to associate the routes used in your site with ASP.NET as you did in ASP.NET 3.5. That's a failing of IIS6 rather than ASP.NET. &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As you can see, setting up routing for an ASP.NET 4.0 webforms site is somewhat simpler than for the previous version as Microsoft has taken the opportunity to refactor routing into the core ASP.NET framework. In the next episode, we'll look at several of the new route-aware features for use once in ASP.NET 4.0 sites we've set routing up. Until then, happy coding!&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=mcRPwwGWFj4:GCS7yUQ25lQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=mcRPwwGWFj4:GCS7yUQ25lQ:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=mcRPwwGWFj4:GCS7yUQ25lQ:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=mcRPwwGWFj4:GCS7yUQ25lQ:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=mcRPwwGWFj4:GCS7yUQ25lQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=mcRPwwGWFj4:GCS7yUQ25lQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=mcRPwwGWFj4:GCS7yUQ25lQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=mcRPwwGWFj4:GCS7yUQ25lQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/mcRPwwGWFj4" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/mcRPwwGWFj4/post.aspx</link>
      <author>DanM</author>
      <comments>http://blog.hmobius.com/post/2010/03/10/ASPNET-40-Part-11-Configuring-Routing-Is-Easier.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=75b9563b-2f08-4470-ad54-407151c0d770</guid>
      <pubDate>Wed, 10 Mar 2010 01:00:00 +0000</pubDate>
      <category>Geek Stuff</category>
      <category>ASP.NET</category>
      <dc:publisher>DanM</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=75b9563b-2f08-4470-ad54-407151c0d770</pingback:target>
      <slash:comments>6</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=75b9563b-2f08-4470-ad54-407151c0d770</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/10/ASPNET-40-Part-11-Configuring-Routing-Is-Easier.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=75b9563b-2f08-4470-ad54-407151c0d770</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=75b9563b-2f08-4470-ad54-407151c0d770</feedburner:origLink></item>
    <item>
      <title>Filmdash 2010</title>
      <description>&lt;p&gt;This year's &lt;a title="FilmDash home" href="http://filmdash.com/" target="_blank"&gt;Filmdash&lt;/a&gt; event took place last weekend in anticipation of The Oscars. This is the rather manic weekend where teams of budding film makers get given the name and theme of a film to make from scratch in 48 hours and don't usually sleep that much. I've done it before but couldn't make it this year. Happily however, Messrs &lt;a rel="met friend" href="http://www.6itbb.com" target="_blank"&gt;Squier&lt;/a&gt; and &lt;a title="James Eaves current work" rel="friend met" href="http://www.youtube.com/watch?v=0QLjXaXF1Eg" target="_blank"&gt;Eaves&lt;/a&gt; carried on regardless and put together the comic &lt;a title="Silence Is Gordon on Youtube" href="http://www.youtube.com/watch?v=CP8avyfIiCw" target="_blank"&gt;Silence is Gordon&lt;/a&gt;. And a little &lt;a title="The Making of Silence Is Gordon on Youtube" href="http://www.youtube.com/watch?v=0QLjXaXF1Eg" target="_blank"&gt;making of...&lt;/a&gt; video too. The Oscars may still be far away but damn it's fun to make films. Well done lads!&lt;/p&gt;
&lt;div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:48f9a2c3-c91e-42c6-8f42-ec77267dd2d2" class="wlWriterEditableSmartContent" style="margin: 0px auto; width: 425px; display: block; float: none; padding: 0px;"&gt;
&lt;div&gt;
&lt;object width="425" height="355"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/CP8avyfIiCw&amp;amp;hl=en" /&gt;&lt;embed type="application/x-shockwave-flash" width="425" height="355" src="http://www.youtube.com/v/CP8avyfIiCw&amp;amp;hl=en"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/div&gt;
&lt;div style="clear:both;font-size:.8em;"&gt;Silence Is Gordon&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=m6kKcQprvzw:INkEAScK4mw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=m6kKcQprvzw:INkEAScK4mw:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=m6kKcQprvzw:INkEAScK4mw:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=m6kKcQprvzw:INkEAScK4mw:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=m6kKcQprvzw:INkEAScK4mw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=m6kKcQprvzw:INkEAScK4mw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=m6kKcQprvzw:INkEAScK4mw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=m6kKcQprvzw:INkEAScK4mw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/m6kKcQprvzw" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/m6kKcQprvzw/post.aspx</link>
      <author>DanM</author>
      <comments>http://blog.hmobius.com/post/2010/03/08/Filmdash-2010.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=0bf90147-2500-4cbe-a918-c869af5d5517</guid>
      <pubDate>Mon, 08 Mar 2010 23:00:00 +0000</pubDate>
      <category>Making Films</category>
      <dc:publisher>DanM</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=0bf90147-2500-4cbe-a918-c869af5d5517</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=0bf90147-2500-4cbe-a918-c869af5d5517</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/08/Filmdash-2010.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=0bf90147-2500-4cbe-a918-c869af5d5517</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=0bf90147-2500-4cbe-a918-c869af5d5517</feedburner:origLink></item>
    <item>
      <title>ASP.NET 4.0 Part 10, A Handful Of Little Things</title>
      <description>&lt;p&gt;Welcome to part 10 of &lt;a href="http://blog.hmobius.com/post/2010/02/09/ASPNET-40-Cometh.aspx"&gt;my tour through ASP.NET 4.0&lt;/a&gt;. In this episode, we’re going to look at a few small but useful additions to the ASP.NET 4.0 webforms template engine before we head out into the wider world of the core framework – routing, caching, sessions and so on.&lt;/p&gt;  &lt;h2&gt;&amp;lt;asp:Chart&amp;gt; Now Built In&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://blog.hmobius.com/image.axd?picture=1_chart.png"&gt;&lt;img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="1_chart" border="0" alt="1_chart" align="left" src="http://blog.hmobius.com/image.axd?picture=1_chart_thumb.png" width="150" height="135" /&gt;&lt;/a&gt; We’ve seen before how Microsoft has folded features from ASP.NET 3.x and other out-of-band releases into the core ASP.NET 4.0 DLLs before. Case in point, the ASP.NET Chart control released in November 2008. This was based on Dundas Chart source code version 5.5 via a Microsoft security, accessibility, and API review. It’s now built into the core which means no additional web.config to get it running and an entry in the Data tab of the standard toolbox set. &lt;/p&gt;  &lt;p&gt;Check out more info on the charting control &lt;a title="ScottGu on the Charting Control" href="http://weblogs.asp.net/scottgu/archive/2010/02/07/built-in-charting-controls-vs-2010-and-net-4-series.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;h2&gt;Three New Redirect Methods&lt;/h2&gt;  &lt;p&gt;The HttpResponse class has been fitted with three new redirect methods, two to work nicely with routing, which we’ll cover later in this series, and the other to play nicer with search engines. &lt;em&gt;Response.RedirectToRoute&lt;/em&gt; and &lt;em&gt;Response.RedirectToRoutePermanent&lt;/em&gt; are the two we'll note in passing for now. As you might suspect, these allow us to redirect users to a page at the end of a route we've defined rather than the page directly. The main difference between the two is that RedirectToRoute sends a &lt;em&gt;HTTP 302 Found&lt;/em&gt; response back to the browser while ResponseToRoutePermanent sends a &lt;em&gt;HTTP 301 Moved Permanently&lt;/em&gt;. To a user, both methods simply redirect their browser to a new page. To a search engine spider, 302 Found implies that the page has moved temporarily, so it will index both the old and new, temporary location. 301 Moved Permanently implies that henceforth the old location is not used and it will only index the new location going forward.&amp;#160; &lt;/p&gt;  &lt;p&gt;The third new redirect method, &lt;em&gt;Response.RedirectPermanent&lt;/em&gt;, also sends a 301 Move Permanently response, but redirects straight to a page rather than a route. It has two overloads like Response.Redirect.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;RedirectPermanent(string url) &lt;/li&gt;    &lt;li&gt;RedirectPermanent(string url, bool endResponse) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The first parameter is simply the URL of the page you wish to redirect to.&lt;/p&gt;  &lt;pre class="brush: csharp; auto-links: false;"&gt;Response.RedirectPermanent(&lt;a href="http://www.danmaharry.com"&gt;http://www.danmaharry.com&lt;/a&gt;);&lt;/pre&gt;

&lt;p&gt;The second parameter lets you specify whether or not ASP.NET should stop processing the page and move straight to processing the Application_EndRequest method in global.asax.cs if you have one. &lt;/p&gt;

&lt;p&gt;Side note: There has always been an issue with Response.Redirect because it calls Response.End internally which can lead to ASP.NET silently throwing ThreadAbortExceptions. &lt;a title="The problem with Response.Redirect" href="http://www.c6software.com/CodeSolutions/dotnet/ThreadAbortException.aspx"&gt;A good thread on this problem can be found here&lt;/a&gt;. The same is likely true of Response.RedirectPermanent, so the upshot is you might want to use these lines of code to avoid the exception being thrown although there are more thorough solutions on offer.&lt;/p&gt;

&lt;pre class="brush: csharp; auto-links: false;"&gt;Response.RedirectPermanent(&amp;quot;http://www.danmaharry.com&amp;quot;, false);
HttpContext.Current.ApplicationInstance.CompleteRequest();&amp;#160; &lt;/pre&gt;

&lt;p&gt;Your mileage may vary with each approach.&lt;/p&gt;

&lt;h2&gt;Inline HTML Encoded Strings&lt;/h2&gt;

&lt;p&gt;Script injection is one of those attack vectors on a website which is easily missed if you're not careful and has the potential for a great deal of grief if you do forget. A first guard against this is to HTMLEncode any user input before being stored in the database or shown on screen. Typically this all done in the code-behind, but the latter can now also be achieved inline using the new &lt;em&gt;&amp;lt;%: message %&amp;gt;&lt;/em&gt; syntax, which will automatically HTML encode the given &lt;em&gt;message&lt;/em&gt; string. For example,&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;p&amp;gt;Unencoded : &amp;lt;script type='text/javascript'&amp;gt;alert('hello');&amp;lt;/script&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;Encoded : &amp;lt;%:&amp;quot;&amp;lt;script type='text/javascript'&amp;gt;alert('hello');&amp;lt;/script&amp;gt;&amp;quot; %&amp;gt;&amp;lt;/p&amp;gt; &lt;/pre&gt;

&lt;p&gt;The top line will have the browser running the javascript in the script tags. The bottom line will HTMLEncode the script tags and produce the following code (on one line - the line returns are for clarity).&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;p&amp;gt;Encoded : 
  &amp;amp;lt;script type=&amp;amp;#39;text/javascript&amp;amp;#39;&amp;amp;gt;alert(&amp;amp;#39;hello&amp;amp;#39;);&amp;amp;lt;/script&amp;amp;gt; 
&amp;lt;/p&amp;gt;&lt;/pre&gt;

&lt;p&gt;Take care not to HTMLEncode a string in code-behind and then also inline with this syntax. ASP.NET will simply HTMLEncode it twice - probably not what you need.&lt;/p&gt;

&lt;p&gt;Side note: Two other items of import with respect to ASP.NET security have happened recently. &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;a title="AntiXSS 3.1 Release Announcement" href="http://blogs.msdn.com/sdl/archive/2009/09/23/new-and-improved-antixss-3-1-now-with-sanitization.aspx"&gt;Anti Cross-Site Scripting library v3.1 was released back in November 2009&lt;/a&gt;. Just after that, the Security Tools team announced they are to incorporate it and several other web security tools into a single amalgam, currently known as the &lt;a title="Web Protection Library anouncement" href="http://blogs.msdn.com/securitytools/archive/2009/10/17/web-protection-library-ctp-release-coming-soon.aspx"&gt;Web Protection Library&lt;/a&gt;. The first CTP of WPL is now available on &lt;a title="Download page for WPL CTP1" href="https://connect.microsoft.com/Downloads/DownloadDetails.aspx?SiteID=734&amp;amp;DownloadID=23329"&gt;the MS Connect site&lt;/a&gt; and there's &lt;a title="&amp;quot;Enhanced Web protection Library&amp;quot; video on Channel 9" href="http://channel9.msdn.com/posts/Jossie/Enhanced-Web-Protection-Library/"&gt;a video on Channel 9&lt;/a&gt; where the contents of WPL are explained. &lt;/li&gt;

  &lt;li&gt;Wrox Press has published the rather splendid Beginning ASP.NET Security, which quite thoroughly covers how to write your websites and web services securely and safely. It's a great little book for beginner to intermediate programmers. Author Barry Dorrans (a &lt;a title="Barry announces his new job" href="http://idunno.org/archive/2009/12/20/and-as-a-finale-to-the-year-hellip.aspx"&gt;newly-minted&lt;/a&gt; member of the MS Security Tools team) is also publishing &lt;a title="Errata for Beginning ASP.NET Security" href="http://idunno.org/Tags/Errata/default.aspx"&gt;any errata found in the book&lt;/a&gt; on his blog as well which is handy. You can get it from &lt;a title="Beginning ASP.NET Security on Amazon US" href="http://www.amazon.com/exec/obidos/ASIN/0470743654/hmobiuscom-20" target="_blank"&gt;Amazon US&lt;/a&gt; and &lt;a title="Beginning ASP.NEt Security on Amazon UK" href="http://www.amazon.co.uk/exec/obidos/ASIN/0470743654/hmobiuscom-21" target="_blank"&gt;Amazon UK&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's all for today. In the next episode, we'll take a look at Routing for Webforms. Happy coding!&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=UVvPCNiWnTQ:ndDwxgemSMU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=UVvPCNiWnTQ:ndDwxgemSMU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=UVvPCNiWnTQ:ndDwxgemSMU:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=UVvPCNiWnTQ:ndDwxgemSMU:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=UVvPCNiWnTQ:ndDwxgemSMU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=UVvPCNiWnTQ:ndDwxgemSMU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=UVvPCNiWnTQ:ndDwxgemSMU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=UVvPCNiWnTQ:ndDwxgemSMU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/UVvPCNiWnTQ" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/UVvPCNiWnTQ/post.aspx</link>
      <author>DanM</author>
      <comments>http://blog.hmobius.com/post/2010/03/04/ASPNET-40-Part-10-A-Handful-Of-Little-Things.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=6226df6f-5668-479c-8415-454cfa162621</guid>
      <pubDate>Thu, 04 Mar 2010 22:00:00 +0000</pubDate>
      <category>ASP.NET</category>
      <category>Geek Stuff</category>
      <dc:publisher>DanM</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=6226df6f-5668-479c-8415-454cfa162621</pingback:target>
      <slash:comments>8</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=6226df6f-5668-479c-8415-454cfa162621</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/04/ASPNET-40-Part-10-A-Handful-Of-Little-Things.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=6226df6f-5668-479c-8415-454cfa162621</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=6226df6f-5668-479c-8415-454cfa162621</feedburner:origLink></item>
    <item>
      <title>UK Events Of Interest (March\April 2010)</title>
      <description>&lt;p&gt;&lt;a title="Scott&amp;#39;s blog" href="http://weblogs.asp.net/scottgu" rel="met"&gt;Scott Guthrie&lt;/a&gt; is coming to the UK for two days. He’ll be in Glasgow and Birmingham on March 25 and 26 respectively. Registration opened today, so click quickly for &lt;a title="Guathon Glasgow" href="http://developerdeveloperdeveloper.com/guglas/"&gt;Glasgow&lt;/a&gt; and &lt;a title="Guathon Birmingham" href="http://developerdeveloperdeveloper.com/gubrum/"&gt;Birmingham&lt;/a&gt; tickets before they are sold out. Both events are free.&lt;/p&gt;  &lt;p&gt;If you can’t make either of those, Microsoft are running &lt;a href="http://www.microsoft.com/uk/techdays/daydev.aspx"&gt;a week of tech days&lt;/a&gt; in London to mark the launch of Visual Studio 2010 and to promote the new Windows 7 Phone platform. They are all in the &lt;a title="View Map for Vue Cinemas" href="http://maps.google.co.uk/maps?hl=en&amp;amp;ie=UTF8&amp;amp;q=vue+6+cinema+broadway+fulham&amp;amp;fb=1&amp;amp;gl=uk&amp;amp;hq=vue+6+cinema+broadway&amp;amp;hnear=fulham&amp;amp;cid=0,0,3037099974638914753&amp;amp;ei=_JaOS8KcB5ey0gTWhYXyDA&amp;amp;ved=0CAcQnwIwAA&amp;amp;z=16&amp;amp;iwloc=A"&gt;Vue 6 Cinema Broadway in Fulham&lt;/a&gt;. [ &lt;a href="http://www.twitter.com/jesseliberty"&gt;Twitter&lt;/a&gt; tweme: #TechDays ]&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="Register for April 12" href="http://msevents.microsoft.com/cui/eventdetail.aspx?eventid=1032442942&amp;amp;culture=en-gb"&gt;April 12&lt;/a&gt; : Visual Studio 2010 – A Path to Big Ideas (for Heads of Development, Dev Managers and Software Architects&lt;/li&gt;    &lt;li&gt;&lt;a title="Add yourself to the wait list for this event" href="http://msevents.microsoft.com/cui/eventdetail.aspx?eventid=1032442951&amp;amp;culture=en-gb"&gt;April 13&lt;/a&gt; : Getting started with .NET Framework 4 and Visual Studio 2010 (for developers : wait list only)&lt;/li&gt;    &lt;li&gt;&lt;a title="Register for this event" href="http://msevents.microsoft.com/cui/eventdetail.aspx?eventid=1032442953&amp;amp;culture=en-gb"&gt;April 14&lt;/a&gt; : The Essential MIX – Highlights from MIX ‘10 with sessions on ASP.NET 4.0, Silverlight 4 and Azure (for developers)&lt;/li&gt;    &lt;li&gt;&lt;a title="Register for this event" href="http://msevents.microsoft.com/cui/eventdetail.aspx?eventid=1032442957&amp;amp;culture=en-gb"&gt;April 15&lt;/a&gt; : Best of Breed Client Applications on Windows 7 – Windows 7 API, Building Rich Clients with .NET 4 and a bit of Azure (for developers)&lt;/li&gt;    &lt;li&gt;April 16 : Windows Phone – Developing for the Windows 7 Phones Series (for developers : registration not up yet)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If you’re a Silverlight fan, then Microsoft’s Silverlight Geek Jesse Liberty is doing &lt;a title="Jesse&amp;#39;s post about the tour" href="http://blogs.silverlight.net/blogs/jesseliberty/archive/2010/04/01/the-united-kingdom-amp-the-republic-of-ireland.aspx"&gt;a 9 day tour of UK&lt;/a&gt; with an extra in Dublin for those in Eire.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;April 12: &lt;a href="http://www.dotnetdevnet.com/"&gt;The .NET Developer Network&lt;/a&gt; in Bristol.&lt;/li&gt;    &lt;li&gt;April 13 and 14:&amp;#160; Microsoft Tech Days, London. &lt;/li&gt;    &lt;li&gt;Tuesday April 13: &lt;a href="http://consultingblogs.emc.com/michelleflynn/archive/2010/02/10/silverlight-user-group-11-video-and-slides.aspx"&gt;Silverlight User Group&lt;/a&gt; /&lt;a href="http://www.dnug.org.uk/"&gt;London .NET User Group&lt;/a&gt;.&lt;/li&gt;    &lt;li&gt;Wednesday April 14: &lt;a href="http://www.nxtgenug.net/"&gt;The Next Generation User Group,&lt;/a&gt; Cambridge.&lt;/li&gt;    &lt;li&gt;Thursday April 15: &lt;a href="http://www.blackmarble.com/"&gt;Black Marble User Group&lt;/a&gt;, Leeds&lt;/li&gt;    &lt;li&gt;Friday April 16: &lt;a href="http://www.nebytes.net/"&gt;NEBytes&lt;/a&gt;, Newcastle Upon Tyne&lt;/li&gt;    &lt;li&gt;Monday April 19 &lt;a href="http://scottishdevelopers.com/"&gt;Scottish Developer’s User Group&lt;/a&gt;, Edinburgh      &lt;br /&gt;Tuesday April 20 &lt;a href="http://scottishdevelopers.com/"&gt;Scottish Developer’s User Group&lt;/a&gt;, Glasgow&lt;/li&gt;    &lt;li&gt;Thursday April 21 Belfast: tbc&lt;/li&gt;    &lt;li&gt;Friday April 22 Dublin: tbc&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Overviews of the talks he’ll be giving can be found &lt;a title="Details of Jesse&amp;#39;s UK Tour" href="http://blogs.silverlight.net/blogs/jesseliberty/archive/2010/04/01/the-united-kingdom-amp-the-republic-of-ireland.aspx"&gt;here on his blog&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Of course, if you’re in the US then you’ve also got &lt;a title="MIX homepage" href="http://visitmix.com/"&gt;MIX 10&lt;/a&gt; (March 15-17), &lt;a title="An Event Apart, Seattle, April 5-7" href="http://aneventapart.com/2010/seattle/"&gt;An Event Apart&lt;/a&gt; (April 5-7), the &lt;a title="Information Architecture Summit 2010" href="http://2010.iasummit.org/"&gt;IA Summit 2010&lt;/a&gt; (April 7-11), and &lt;a title="Chirp homepage" href="http://chirp.twitter.com/"&gt;Chirp : The Twitter Dev Conference&lt;/a&gt; (April 14 –15) to attend, so it’s not all bad really, is it?&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=qt8blYXAgz4:rApxEA7rKPI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=qt8blYXAgz4:rApxEA7rKPI:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=qt8blYXAgz4:rApxEA7rKPI:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=qt8blYXAgz4:rApxEA7rKPI:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=qt8blYXAgz4:rApxEA7rKPI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=qt8blYXAgz4:rApxEA7rKPI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=qt8blYXAgz4:rApxEA7rKPI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=qt8blYXAgz4:rApxEA7rKPI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/qt8blYXAgz4" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/qt8blYXAgz4/post.aspx</link>
      <author>obiwan</author>
      <comments>http://blog.hmobius.com/post/2010/03/03/UK-Events-Of-Interest-(March5cApril-2010).aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=440e6815-2a35-4c27-a5dc-7e85ff2cf71c</guid>
      <pubDate>Wed, 03 Mar 2010 17:00:00 +0000</pubDate>
      <category>Attending Events</category>
      <category>Geek Stuff</category>
      <dc:publisher>obiwan</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=440e6815-2a35-4c27-a5dc-7e85ff2cf71c</pingback:target>
      <slash:comments>3</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=440e6815-2a35-4c27-a5dc-7e85ff2cf71c</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/03/UK-Events-Of-Interest-(March5cApril-2010).aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=440e6815-2a35-4c27-a5dc-7e85ff2cf71c</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=440e6815-2a35-4c27-a5dc-7e85ff2cf71c</feedburner:origLink></item>
    <item>
      <title>Today's Bookmarks (March 3 2010)</title>
      <description>&lt;ul class="delicious"&gt;
&lt;li&gt;
&lt;div class="delicious-link"&gt;&lt;a href="http://www.jquery.wisdomplug.com/jquery-plugins/jquery-user-interface-plugins-jquery-plugins/20-impressive-jquery-button-plugins/"&gt;20 Impressive jQuery Button Plugins&lt;/a&gt;&lt;/div&gt;
&lt;div class="delicious-extended"&gt;Nice article about different things you can do with a button and some jQuery&lt;/div&gt;
&lt;div class="delicious-tags"&gt;(tags: &lt;a href="http://delicious.com/hmobius/javascript"&gt;javascript&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/jquery"&gt;jquery&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/tutorial"&gt;tutorial&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/ui"&gt;ui&lt;/a&gt;)&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div class="delicious-link"&gt;&lt;a href="http://www.stumbleupon.com/su/1P6XnB/www.noupe.com/how-tos/designers-how-to-search-for-hire-and-work-with-a-web-developer.html"&gt;How to Search For, Hire, and Work With a Web Developer&lt;/a&gt;&lt;/div&gt;
&lt;div class="delicious-extended"&gt;Neat article for designers outlining a few simple guidelines for finding a developer to implement your designs&lt;/div&gt;
&lt;div class="delicious-tags"&gt;(tags: &lt;a rel="tags" href="http://delicious.com/hmobius/freelance"&gt;freelance&lt;/a&gt; &lt;a rel="tags" href="http://delicious.com/hmobius/jobs"&gt;jobs&lt;/a&gt;)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=044aPLF-4bY:lKx4povgsZ4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=044aPLF-4bY:lKx4povgsZ4:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=044aPLF-4bY:lKx4povgsZ4:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=044aPLF-4bY:lKx4povgsZ4:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=044aPLF-4bY:lKx4povgsZ4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=044aPLF-4bY:lKx4povgsZ4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=044aPLF-4bY:lKx4povgsZ4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=044aPLF-4bY:lKx4povgsZ4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/044aPLF-4bY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/044aPLF-4bY/post.aspx</link>
      <author>Dan@Delicious</author>
      <comments>http://blog.hmobius.com/post/2010/03/03/Todays-Bookmarks-(March-3-2010).aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=e6941a7f-9141-4e1a-9c9e-99469891fd84</guid>
      <pubDate>Wed, 03 Mar 2010 05:03:00 +0000</pubDate>
      <category>Bookmarks</category>
      <dc:publisher>Dan@Delicious</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=e6941a7f-9141-4e1a-9c9e-99469891fd84</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=e6941a7f-9141-4e1a-9c9e-99469891fd84</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/03/Todays-Bookmarks-(March-3-2010).aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=e6941a7f-9141-4e1a-9c9e-99469891fd84</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=e6941a7f-9141-4e1a-9c9e-99469891fd84</feedburner:origLink></item>
    <item>
      <title>ASP.NET, Part 9: Rendering Cleaner HTML</title>
      <description>&lt;p&gt;Welcome to part 9 of &lt;a href="http://blog.hmobius.com/post/2010/02/09/ASPNET-40-Cometh.aspx"&gt;my tour through ASP.NET 4.0&lt;/a&gt;. In this episode, we’ll conclude our look at the ways that ASP.NET has been tweaked in v4.0 to produce cleaner, leaner HTML that we can turn to our purpose without having to deal with some of the inconveniences of previous versions – control IDs and injected HTML we can’t control being two. More control over viewstate being a third.&lt;/p&gt;  &lt;h2&gt;ASP.NET 2.0: Only Technically Standards Compliant…&lt;/h2&gt;  &lt;p&gt;Even in 2005, the idea of producing pure HTML\CSS websites had gained quite a foothold. XHTML had been a W3C Recommendation since 2001 and CSS was evolving and being used more prevalently. Sites like &lt;a title="CSS Zen Garden" href="http://www.csszengarden.com"&gt;CSS Zen Garden&lt;/a&gt; had been championing cross-browser sites and advanced layouts with this approach for a couple of years. All it required was control over the HTML generated by your site and some reasoned application of CSS.&lt;/p&gt;  &lt;p&gt;Regrettably, ASP.NET 1.1 didn’t produce standards-compliant HTML at all, so ASP.NET 2.0 created a new setting in web.config called &lt;a title="MSDN entry on xhtmlConformance" href="http://msdn.microsoft.com/en-gb/library/ms228268(loband).aspx"&gt;xhtmlConformance&lt;/a&gt; that would determine how its server controls were to be rendered as HTML. By default, controls would render markup compatible with the XHTML 1.0 Transitional standard (Transitional). Alternatively, the setting could be changed to have ASP.NET render markup compatible with XHTML 1.0 Strict (Strict) or as v1.1 (Legacy) has rendered it before. Websites upgraded from v1.1 to v2.0 were set to this Legacy mode.&lt;/p&gt;  &lt;p&gt;Unfortunately, &lt;a title="Note from ScottGu about running Legacy rendering against ASP.NET AJAX" href="http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx"&gt;sites running in Legacy mode didn’t work with ASP.NET AJAX&lt;/a&gt; and while Transitional and Strict modes were technically compliant with the XHTML 1.0 standard, they could equally have been described as CSS-intolerant. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Menus were rendered as tables rather than lists (not only harder to work with in CSS, but semantically wrong too)&lt;/li&gt;    &lt;li&gt;Several properties like border=0 or disabled=disabled were mandatorily added to various elements without a way to remove them.&lt;/li&gt;    &lt;li&gt;For templated controls, you had full control over the templates themselves, but not over the outer table that surrounded the templates.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Technically correct, but not a good foundation to build standards compliant sites upon. The introduction of the &lt;a title="ListView on MSDN" href="http://msdn.microsoft.com/en-gb/library/system.web.ui.webcontrols.listview.aspx"&gt;ListView&lt;/a&gt; &amp;amp; &lt;a href="http://msdn.microsoft.com/en-gb/library/system.web.ui.webcontrols.datapager.aspx"&gt;DataPager&lt;/a&gt; controls in ASP.NET 3.5 and the out of band &lt;a title="CSS Firendly Adapters on Codeplex" href="http://www.codeplex.com/cssfriendly"&gt;CSS Control Adapters&lt;/a&gt; release helped somewhat but it’s only because they’ve been able to go into System.Web for .NET 4.0 that Microsoft have been able to make ASP.NET (mostly) CSS-friendly. Indeed, emitting cleaner markup was one of the main goals for ASP.NET 4.0&lt;/p&gt;  &lt;h2&gt;ControlRenderingCompatibilityVersion&lt;/h2&gt;  &lt;p&gt;Like xhtmlConformance in ASP.NET 2.0, a new setting is now available in web.config to control how controls render HTML. It is called &lt;em&gt;ControlRenderingCompatibilityVersion&lt;/em&gt;.&lt;/p&gt;  &lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;system.web&amp;gt;
    &amp;lt;compilation debug=&amp;quot;false&amp;quot; targetFramework=&amp;quot;4.0&amp;quot; /&amp;gt;

    &amp;lt;pages controlRenderingCompatibilityVersion=&amp;quot;3.5&amp;quot; /&amp;gt;

  &amp;lt;/system.web&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;

&lt;p&gt;CRCV, as we’ll call it, takes one of two values. Set it to &lt;em&gt;3.5&lt;/em&gt; (the default for sites upgraded from ASP.NET 3.5) and all server controls will render as they did in ASP.NET 3.5. Set it to &lt;em&gt;4.0&lt;/em&gt; (the default for new web site and web application projects) and the following happens&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;xhtmlConformance is set to &lt;em&gt;Strict&lt;/em&gt;.&lt;/li&gt;

  &lt;li&gt;Menus are rendered as lists rather than tables&lt;/li&gt;

  &lt;li&gt;Extraneous properties like border=0 are removed from the emitted markup. Even the error text on validation controls is no longer set to red.&lt;/li&gt;

  &lt;li&gt;The rendering of the outer table for templated controls can now be controlled with the new &lt;strong&gt;RenderOuterTable&lt;/strong&gt; property.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s look at these changes in detail.&lt;/p&gt;

&lt;h2&gt;Menus&lt;/h2&gt;

&lt;p&gt;Let’s consider a very simple menu control with three items.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;asp:Menu runat=&amp;quot;server&amp;quot; ID=&amp;quot;testMenu&amp;quot;&amp;gt;
  &amp;lt;Items&amp;gt;
    &amp;lt;asp:MenuItem Text=&amp;quot;Menu Item 1&amp;quot; NavigateUrl=&amp;quot;#&amp;quot;&amp;gt;&amp;lt;/asp:MenuItem&amp;gt;
    &amp;lt;asp:MenuItem Text=&amp;quot;Menu Item 2&amp;quot; NavigateUrl=&amp;quot;#&amp;quot;&amp;gt;&amp;lt;/asp:MenuItem&amp;gt;
    &amp;lt;asp:MenuItem Text=&amp;quot;Menu Item 3&amp;quot; NavigateUrl=&amp;quot;#&amp;quot;&amp;gt;&amp;lt;/asp:MenuItem&amp;gt;
  &amp;lt;/Items&amp;gt;
&amp;lt;/asp:Menu&amp;gt;&lt;/pre&gt;

&lt;p&gt;With CRCV set to 3.5, we get three CSS styles for the menu added to the HTML &amp;lt;head&amp;gt;, 53KB of script files added in by two calls to WebResource.axd (21KB for the standard script to handle postbacks, 32KB for a menu-specific script file), and the following HTML for the menu itself.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;body&amp;gt;
  &amp;lt;div&amp;gt;
  &amp;lt;a href=&amp;quot;#testMenu_SkipLink&amp;quot;&amp;gt;
    &amp;lt;img alt=&amp;quot;Skip Navigation Links&amp;quot; width=&amp;quot;0&amp;quot; height=&amp;quot;0&amp;quot; style=&amp;quot;border-width:0px;&amp;quot;
      src=&amp;quot;/CleanHtml/WebResource.axd?d=y4UEb5xFzNnwyKsjxERYdw2&amp;amp;amp;t=634013486901596851&amp;quot; /&amp;gt;
  &amp;lt;/a&amp;gt;
  &amp;lt;table id=&amp;quot;testMenu&amp;quot; class=&amp;quot;testMenu_2&amp;quot; cellpadding=&amp;quot;0&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&amp;gt;
    &amp;lt;tr onmouseover=&amp;quot;Menu_HoverStatic(this)&amp;quot; onmouseout=&amp;quot;Menu_Unhover(this)&amp;quot; 
      onkeyup=&amp;quot;Menu_Key(this)&amp;quot; id=&amp;quot;testMenun0&amp;quot;&amp;gt;
      &amp;lt;td&amp;gt;
        &amp;lt;table cellpadding=&amp;quot;0&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; width=&amp;quot;100%&amp;quot;&amp;gt;
          &amp;lt;tr&amp;gt;
            &amp;lt;td style=&amp;quot;white-space:nowrap;width:100%;&amp;quot;&amp;gt;
              &amp;lt;a class=&amp;quot;testMenu_1&amp;quot; href=&amp;quot;#&amp;quot;&amp;gt;Menu Item 1&amp;lt;/a&amp;gt;
            &amp;lt;/td&amp;gt;
          &amp;lt;/tr&amp;gt;
        &amp;lt;/table&amp;gt;
      &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
    &amp;lt;tr onmouseover=&amp;quot;Menu_HoverStatic(this)&amp;quot; onmouseout=&amp;quot;Menu_Unhover(this)&amp;quot; 
      onkeyup=&amp;quot;Menu_Key(this)&amp;quot; id=&amp;quot;testMenun0&amp;quot;&amp;gt;
      &amp;lt;td&amp;gt;
        &amp;lt;table cellpadding=&amp;quot;0&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; width=&amp;quot;100%&amp;quot;&amp;gt;
          &amp;lt;tr&amp;gt;
            &amp;lt;td style=&amp;quot;white-space:nowrap;width:100%;&amp;quot;&amp;gt;
              &amp;lt;a class=&amp;quot;testMenu_1&amp;quot; href=&amp;quot;#&amp;quot;&amp;gt;Menu Item 2&amp;lt;/a&amp;gt;
            &amp;lt;/td&amp;gt;
          &amp;lt;/tr&amp;gt;
        &amp;lt;/table&amp;gt;
      &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
    &amp;lt;tr onmouseover=&amp;quot;Menu_HoverStatic(this)&amp;quot; onmouseout=&amp;quot;Menu_Unhover(this)&amp;quot; 
      onkeyup=&amp;quot;Menu_Key(this)&amp;quot; id=&amp;quot;testMenun0&amp;quot;&amp;gt;
      &amp;lt;td&amp;gt;
        &amp;lt;table cellpadding=&amp;quot;0&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; width=&amp;quot;100%&amp;quot;&amp;gt;
          &amp;lt;tr&amp;gt;
            &amp;lt;td style=&amp;quot;white-space:nowrap;width:100%;&amp;quot;&amp;gt;
              &amp;lt;a class=&amp;quot;testMenu_1&amp;quot; href=&amp;quot;#&amp;quot;&amp;gt;Menu Item 3&amp;lt;/a&amp;gt;
            &amp;lt;/td&amp;gt;
          &amp;lt;/tr&amp;gt;
        &amp;lt;/table&amp;gt;
      &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
  &amp;lt;/table&amp;gt;
  &amp;lt;a id=&amp;quot;testMenu_SkipLink&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;
  &amp;lt;/div&amp;gt; 
  &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt; 
    //&amp;lt;![CDATA[
    var testMenu_Data = new Object();
    testMenu_Data.disappearAfter = 500;
    testMenu_Data.horizontalOffset = 0;
    testMenu_Data.verticalOffset = 0;
    //]]&amp;gt;
  &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;&lt;/pre&gt;

&lt;p&gt;With CRCV set to 4.0, we get six CSS styles added to the &amp;lt;head&amp;gt; element, a single 27KB script file downloaded to the browser (a completely refactored version of the menu script) and the following HTML for the menu.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;body&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;a href=&amp;quot;#testMenu_SkipLink&amp;quot;&amp;gt;
    &amp;lt;img alt=&amp;quot;Skip Navigation Links&amp;quot; width=&amp;quot;0&amp;quot; height=&amp;quot;0&amp;quot; style=&amp;quot;border-width:0px;&amp;quot; 
      src=&amp;quot;/CleanHtml/WebResource.axd?d=y4UEb5xFzNnwyKsjxERYdw2&amp;amp;amp;t=634013486901596851&amp;quot; /&amp;gt;
    &amp;lt;/a&amp;gt;
    &amp;lt;div id=&amp;quot;testMenu&amp;quot;&amp;gt;
    &amp;lt;ul class=&amp;quot;level1&amp;quot;&amp;gt;
      &amp;lt;li&amp;gt;&amp;lt;a class=&amp;quot;level1&amp;quot; href=&amp;quot;#&amp;quot;&amp;gt;Menu Item 1&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;&amp;lt;a class=&amp;quot;level1&amp;quot; href=&amp;quot;#&amp;quot;&amp;gt;Menu Item 2&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;&amp;lt;a class=&amp;quot;level1&amp;quot; href=&amp;quot;#&amp;quot;&amp;gt;Menu Item 3&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;a id=&amp;quot;testMenu_SkipLink&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;script type='text/javascript'&amp;gt;
    new Sys.WebForms.Menu({ 
      element: 'testMenu', 
      disappearAfter: 500, 
      orientation: 'vertical', 
      tabIndex: 0, 
      disabled: false });
  &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;&lt;/pre&gt;

&lt;p&gt;As you can see, not only is the rendered HTML semantically correct, the overall payload is smaller as well. Indeed you can reduce it further by setting the Menu control’s &lt;em&gt;IncludeStyleBlock&lt;/em&gt; property to false. This will remove the six styles added to the &amp;lt;head&amp;gt; element for you to include in your own CSS files. Finally, note that you can set the Menu control’s RenderingMode property to either List, Table or Default. This will override the CRCV setting and render the menu as either List or Table as you’ve set it.&lt;/p&gt;

&lt;h2&gt;Extraneous HTML&lt;/h2&gt;

&lt;p&gt;The Image control is a good example of a control that in ASP.NET 3.5 added a property to the emitted HTML that wasn’t asked for and couldn’t be overridden. Take a very simple declaration&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;asp:Image runat=&amp;quot;server&amp;quot; ID=&amp;quot;imgMorgan&amp;quot; ImageUrl=&amp;quot;~/morgan.jpg&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;With CRCV set to 3.5, ASP.NET sets the image’s border-width to 0px.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;img id=&amp;quot;imgMorgan&amp;quot; src=&amp;quot;morgan.jpg&amp;quot; style=&amp;quot;border-width:0px;&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;With CRCV set to 4.0, there’s no sign of the style property at all.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;img id=&amp;quot;imgMorgan&amp;quot; src=&amp;quot;morgan.jpg&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;Other controls, such as Table and GridView are similarly shed of their extraneous properties.&lt;/p&gt;

&lt;h2&gt;Removing The Outer Table From Some Composite Controls&lt;/h2&gt;

&lt;p&gt;For the most part, ASP.NET controls will render the HTML you want them to, but it looks like some of the more complex, composite controls haven’t been ‘sanitized’ in the same way as more commonly used controls such as the Image or DropDownList. However, it is worth noting that some of these controls now have a new property called RenderOuterTable which does address one particular markup issue. These are&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;FormView&lt;/li&gt;

  &lt;li&gt;Login&lt;/li&gt;

  &lt;li&gt;ChangePassword&lt;/li&gt;

  &lt;li&gt;PasswordRecovery&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Take for example the Login control. &lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;asp:Login runat=&amp;quot;server&amp;quot; ID=&amp;quot;loginTest&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;Whether CRCV is set to 3.5 or 4.0, the default markup is the same.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;table cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot; border=&amp;quot;0&amp;quot; 
  id=&amp;quot;loginTest&amp;quot; style=&amp;quot;border-collapse:collapse;&amp;quot;&amp;gt;
  &amp;lt;tr&amp;gt;
    &amp;lt;td&amp;gt;
      &amp;lt;table cellpadding=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&amp;gt;
        &amp;lt;tr&amp;gt;
          &amp;lt;td align=&amp;quot;center&amp;quot; colspan=&amp;quot;2&amp;quot;&amp;gt;Log In&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
          &amp;lt;td align=&amp;quot;right&amp;quot;&amp;gt;
            &amp;lt;label for=&amp;quot;loginTest_UserName&amp;quot;&amp;gt;User Name:&amp;lt;/label&amp;gt;
          &amp;lt;/td&amp;gt;
          &amp;lt;td&amp;gt;
            &amp;lt;input name=&amp;quot;loginTest$UserName&amp;quot; type=&amp;quot;text&amp;quot; id=&amp;quot;loginTest_UserName&amp;quot; /&amp;gt;
            &amp;lt;span id=&amp;quot;loginTest_UserNameRequired&amp;quot; title=&amp;quot;User Name is required.&amp;quot; 
              style=&amp;quot;color:Red;visibility:hidden;&amp;quot;&amp;gt;*&amp;lt;/span&amp;gt;
          &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
          &amp;lt;td align=&amp;quot;right&amp;quot;&amp;gt;
            &amp;lt;label for=&amp;quot;loginTest_Password&amp;quot;&amp;gt;Password:&amp;lt;/label&amp;gt;
          &amp;lt;/td&amp;gt;
          &amp;lt;td&amp;gt;
            &amp;lt;input name=&amp;quot;loginTest$Password&amp;quot; type=&amp;quot;password&amp;quot; id=&amp;quot;loginTest_Password&amp;quot; /&amp;gt;
            &amp;lt;span id=&amp;quot;loginTest_PasswordRequired&amp;quot; title=&amp;quot;Password is required.&amp;quot; 
              style=&amp;quot;color:Red;visibility:hidden;&amp;quot;&amp;gt;*&amp;lt;/span&amp;gt;
          &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
          &amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;
            &amp;lt;input id=&amp;quot;loginTest_RememberMe&amp;quot; type=&amp;quot;checkbox&amp;quot; name=&amp;quot;loginTest$RememberMe&amp;quot; /&amp;gt;
            &amp;lt;label for=&amp;quot;loginTest_RememberMe&amp;quot;&amp;gt;Remember me next time.&amp;lt;/label&amp;gt;
          &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
          &amp;lt;td align=&amp;quot;right&amp;quot; colspan=&amp;quot;2&amp;quot;&amp;gt;
            &amp;lt;input type=&amp;quot;submit&amp;quot; name=&amp;quot;loginTest$LoginButton&amp;quot; value=&amp;quot;Log In&amp;quot; 
              onclick=&amp;quot;…&amp;quot; id=&amp;quot;loginTest_LoginButton&amp;quot; /&amp;gt;
          &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;&lt;/pre&gt;

&lt;p&gt;A CSS-related issue with this in earlier versions of ASP.NET is the outer table which you haven’t previously been able to remove (but which ironically was added as a wrapper in to give you better control over your styles). Set the Login control’s RenderOuterTable property to &lt;em&gt;false&lt;/em&gt; and this will lose that table no matter what CVCR is set to.&lt;/p&gt;

&lt;pre class="brush: xml; auto-links: false;"&gt;&amp;lt;table cellpadding=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&amp;gt;
  &amp;lt;tr&amp;gt;
    &amp;lt;td align=&amp;quot;center&amp;quot; colspan=&amp;quot;2&amp;quot;&amp;gt;Log In&amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
  &amp;lt;tr&amp;gt;
    &amp;lt;td align=&amp;quot;right&amp;quot;&amp;gt;
      &amp;lt;label for=&amp;quot;loginTest_UserName&amp;quot;&amp;gt;User Name:&amp;lt;/label&amp;gt;
    &amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;
      &amp;lt;input name=&amp;quot;loginTest$UserName&amp;quot; type=&amp;quot;text&amp;quot; id=&amp;quot;loginTest_UserName&amp;quot; /&amp;gt;
      &amp;lt;span id=&amp;quot;loginTest_UserNameRequired&amp;quot; title=&amp;quot;User Name is required.&amp;quot; 
        style=&amp;quot;color:Red;visibility:hidden;&amp;quot;&amp;gt;*&amp;lt;/span&amp;gt;
    &amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
  &amp;lt;tr&amp;gt;
    &amp;lt;td align=&amp;quot;right&amp;quot;&amp;gt;
      &amp;lt;label for=&amp;quot;loginTest_Password&amp;quot;&amp;gt;Password:&amp;lt;/label&amp;gt;
    &amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;
      &amp;lt;input name=&amp;quot;loginTest$Password&amp;quot; type=&amp;quot;password&amp;quot; id=&amp;quot;loginTest_Password&amp;quot; /&amp;gt;
      &amp;lt;span id=&amp;quot;loginTest_PasswordRequired&amp;quot; title=&amp;quot;Password is required.&amp;quot; 
        style=&amp;quot;color:Red;visibility:hidden;&amp;quot;&amp;gt;*&amp;lt;/span&amp;gt;
    &amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
  &amp;lt;tr&amp;gt;
    &amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;
      &amp;lt;input id=&amp;quot;loginTest_RememberMe&amp;quot; type=&amp;quot;checkbox&amp;quot; name=&amp;quot;loginTest$RememberMe&amp;quot; /&amp;gt;
      &amp;lt;label for=&amp;quot;loginTest_RememberMe&amp;quot;&amp;gt;Remember me next time.&amp;lt;/label&amp;gt;
    &amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
  &amp;lt;tr&amp;gt;
    &amp;lt;td align=&amp;quot;right&amp;quot; colspan=&amp;quot;2&amp;quot;&amp;gt;
      &amp;lt;input type=&amp;quot;submit&amp;quot; name=&amp;quot;loginTest$LoginButton&amp;quot; value=&amp;quot;Log In&amp;quot; 
        onclick=&amp;quot;…&amp;quot; id=&amp;quot;loginTest_LoginButton&amp;quot; /&amp;gt;
    &amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;&lt;/pre&gt;

&lt;p&gt;Not ground-shattering certainly, but definitely handy. &lt;/p&gt;

&lt;h2&gt;What We’ve Learnt&lt;/h2&gt;

&lt;p&gt;In today’s episode, we’ve learnt that Microsoft has taken the opportunity in ASP.NET 4.0 to clean up a great deal of the HTML emitted by its server controls, thus making it CSS-friendlier. A new setting in web.config called &lt;em&gt;ControlRenderingCompatibilityVersion&lt;/em&gt; indicates whether controls should render as cleaner HTML or as they did in 3.5. We saw two example of the cleaner HTML in effect in the Menu and Image control and noted that while some of the more complex controls have not had their markup cleaned up, a subset of those now have a RenderOuterTable property which allows you to remove some of it manually.&lt;/p&gt;

&lt;p&gt;Incidentally, for those of you with sites that you can’t upgrade to .NET 4.0, a group of enterprising souls are continuing to work on the CSS Friendly Adapters mentioned earlier. You’ll find this revitalization &lt;a title="CSS Friendly Adapters projec on Google Code" href="http://code.google.com/p/aspnetcontroladapters/"&gt;here on Google Code&lt;/a&gt;. Happy coding!&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CvxO_wu5i8U:pG9BF8wD01U:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CvxO_wu5i8U:pG9BF8wD01U:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CvxO_wu5i8U:pG9BF8wD01U:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=CvxO_wu5i8U:pG9BF8wD01U:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CvxO_wu5i8U:pG9BF8wD01U:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=CvxO_wu5i8U:pG9BF8wD01U:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=CvxO_wu5i8U:pG9BF8wD01U:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=CvxO_wu5i8U:pG9BF8wD01U:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/CvxO_wu5i8U" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/CvxO_wu5i8U/post.aspx</link>
      <author>DanM</author>
      <comments>http://blog.hmobius.com/post/2010/03/03/ASPNET-Part-9-Rendering-Cleaner-HTML.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=c95fc991-7c02-45cf-a07b-663fd5d8d2b8</guid>
      <pubDate>Wed, 03 Mar 2010 02:00:00 +0000</pubDate>
      <category>ASP.NET</category>
      <category>Geek Stuff</category>
      <dc:publisher>DanM</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=c95fc991-7c02-45cf-a07b-663fd5d8d2b8</pingback:target>
      <slash:comments>3</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=c95fc991-7c02-45cf-a07b-663fd5d8d2b8</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/03/03/ASPNET-Part-9-Rendering-Cleaner-HTML.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=c95fc991-7c02-45cf-a07b-663fd5d8d2b8</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=c95fc991-7c02-45cf-a07b-663fd5d8d2b8</feedburner:origLink></item>
    <item>
      <title>Today's Bookmarks (25 Feb 2010)</title>
      <description>&lt;ul class="delicious"&gt;
&lt;li&gt;
&lt;div class="delicious-link"&gt;&lt;a href="http://blogs.msdn.com/aspnetue/archive/2010/02/23/asp-net-topics-on-msdn-the-top-10-list.aspx"&gt;ASP.NET Topics on MSDN &amp;ndash; The Top 10 List&lt;/a&gt;&lt;/div&gt;
&lt;div class="delicious-extended"&gt;Links pointing to the most popular ASP.NET topics on MSDN over the last year (02/2009 to 02/2010).&lt;/div&gt;
&lt;div class="delicious-tags"&gt;(tags: &lt;a rel="tag" href="http://delicious.com/hmobius/asp.net"&gt;asp.net&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/documentation"&gt;documentation&lt;/a&gt;)&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div class="delicious-link"&gt;&lt;a href="http://code.msdn.microsoft.com/Project/ProjectDirectory.aspx?TagName=WebAppToolkits"&gt;Microsoft Web App Toolkits&lt;/a&gt;&lt;/div&gt;
&lt;div class="delicious-extended"&gt;List of currently available web app toolkits on MSDN Code Gallery. Full docs as well&lt;/div&gt;
&lt;div class="delicious-tags"&gt;(tags: &lt;a href="http://delicious.com/hmobius/asp.net"&gt;asp.net&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/tools"&gt;tools&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/rest"&gt;rest&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/c%23"&gt;c#&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/tutorial"&gt;tutorial&lt;/a&gt; &lt;a rel="tag" href="http://delicious.com/hmobius/documentation"&gt;documentation&lt;/a&gt;)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=8FYuwFGp4_Q:QzDwTLP2dc8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=8FYuwFGp4_Q:QzDwTLP2dc8:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=8FYuwFGp4_Q:QzDwTLP2dc8:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=8FYuwFGp4_Q:QzDwTLP2dc8:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=8FYuwFGp4_Q:QzDwTLP2dc8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=8FYuwFGp4_Q:QzDwTLP2dc8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DansArchive?a=8FYuwFGp4_Q:QzDwTLP2dc8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DansArchive?i=8FYuwFGp4_Q:QzDwTLP2dc8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DansArchive/~4/8FYuwFGp4_Q" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/DansArchive/~3/8FYuwFGp4_Q/post.aspx</link>
      <author>Dan@Delicious</author>
      <comments>http://blog.hmobius.com/post/2010/02/25/Todays-Bookmarks-(25-Feb-2010).aspx#comment</comments>
      <guid isPermaLink="false">http://blog.hmobius.com/post.aspx?id=43d347b3-891f-4b2c-a15c-2055444daced</guid>
      <pubDate>Thu, 25 Feb 2010 05:04:00 +0000</pubDate>
      <category>Bookmarks</category>
      <dc:publisher>Dan@Delicious</dc:publisher>
      <pingback:server>http://blog.hmobius.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.hmobius.com/post.aspx?id=43d347b3-891f-4b2c-a15c-2055444daced</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.hmobius.com/trackback.axd?id=43d347b3-891f-4b2c-a15c-2055444daced</trackback:ping>
      <wfw:comment>http://blog.hmobius.com/post/2010/02/25/Todays-Bookmarks-(25-Feb-2010).aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.hmobius.com/syndication.axd?post=43d347b3-891f-4b2c-a15c-2055444daced</wfw:commentRss>
    <feedburner:origLink>http://blog.hmobius.com/post.aspx?id=43d347b3-891f-4b2c-a15c-2055444daced</feedburner:origLink></item>
  </channel>
</rss>
