<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christopher H. Laco &#187; Microsoft</title>
	<atom:link href="http://chrislaco.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrislaco.com</link>
	<description></description>
	<lastBuildDate>Wed, 28 Jul 2010 00:21:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WebFormViewEngine Path Defaults Seem Broken</title>
		<link>http://chrislaco.com/microsoft/webformviewengine-path-defaults-seem-broken/</link>
		<comments>http://chrislaco.com/microsoft/webformviewengine-path-defaults-seem-broken/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 03:54:07 +0000</pubDate>
		<dc:creator>claco</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://chrislaco.com/?p=239</guid>
		<description><![CDATA[This post is about 60% fact and 40% opinion. Not a bad ratio. I&#8217;ve been working a lot in ASP.NET MVC lately building up a set of classes to be reused across multiple sites in the near future. A few &#8230; <a href="http://chrislaco.com/microsoft/webformviewengine-path-defaults-seem-broken/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post is about 60% fact and 40% opinion. Not a bad ratio. I&#8217;ve been working a lot in ASP.NET MVC lately building up a set of classes to be reused across multiple sites in the near future. A few of these legos are small view classes that inherit from <code>WebFormViewEngine</code>. They all do small things, like adding additional file search paths, loading views from resources and fetching views from remote storage. Since you can stack view engines in <code>ViewEngines.Engines</code>, you can add and number of these engines together to get the functionality you want on a site per site basis. First engine to claim it can service a view wins. Nothing special there really.</p>
<p>I stumbled across something today that seems obvious in retrospect that leads me to the opinion that the default view/partial view search patterns are broken. If you crack open Reflector.NET and point it towards <code>WebFormViewEngine</code>, you&#8217;ll see that <code>ViewLocationFormats</code> and <code>PartialViewLocationFormats</code> are declared the same:</p>
<pre style="padding-left: 30px;">~/Views/{1}/{0}.aspx</pre>
<pre style="padding-left: 30px;">~/Views/{1}/{0}.ascx</pre>
<pre style="padding-left: 30px;">~/Views/Shared/{0}.aspx</pre>
<pre style="padding-left: 30px;">~/Views/Shared/{0}.ascx</pre>
<p><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">In other words, for the <code>Index</code> action on the <code>Home</code> controller, the following paths are searched:</span></p>
<pre style="padding-left: 30px;">~/Views/Home/Index.aspx</pre>
<pre style="padding-left: 30px;">~/Views/Home/Index.ascx</pre>
<pre style="padding-left: 30px;">~/Views/Shared/Index.aspx</pre>
<pre style="padding-left: 30px;">~/Views/Shared/Index.ascx</pre>
<p>This all seems well and good until you happen to have a partial view that has the same name as an action that either happens to be shared, or the parti is being overridden in the local controllers folder. Here&#8217;s a somewhat plausible example: A <code>Search</code> controller with an <code>Items</code> action:</p>
<pre style="padding-left: 30px;">~/Views/Search/Items.aspx</pre>
<pre style="padding-left: 30px;">    (the view page for the Items action)</pre>
<pre style="padding-left: 30px;">~/Views/Home/Index.ascx</pre>
<pre style="padding-left: 30px;">    (possibly an items partial view customized just for this controller/action)</pre>
<pre style="padding-left: 30px;">~/Views/Shared/Items.ascx</pre>
<pre style="padding-left: 30px;">    (the shared partial view to render items in many controllers/actions/views)</pre>
<p>This is where the problems start. By default, a call to <code>RenderPartial("Items")</code> within the <code>Items.aspx</code> page is going to find the <code>Items.aspx</code> file first and not the <code>Items.ascx</code>. I&#8217;ve never ever seen anyone in the wild put <em>partial views</em> in an <em>aspx</em> file nor have I ever seen anyone put a full <em>action view</em> in an <em>ascx</em> file. So why on earth did they all them to be interchangeable in the location paths? Broken I say. Broken.</p>
<p>The good news is that it&#8217;s super easy to tweak these kinds of things in ASP.NET MVC. Inherit from <code>WebFormViewEngine</code> and set your own <code>ViewLocationFormats</code> and <code>PartialViewLocationFormats</code>. I my case I decided to force the issue explicitly. <code>ViewLocationFormats</code> <em>only looks for aspx</em> files and <code>PartialViewLocationFormats</code> <code>only look for ascx</code> files. Now we can override shared partial views locally in controller folders without worrying about name collisions.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrislaco.com/microsoft/webformviewengine-path-defaults-seem-broken/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7: What Vista Should Have Been</title>
		<link>http://chrislaco.com/microsoft/windows-7-what-vista-should-have-been/</link>
		<comments>http://chrislaco.com/microsoft/windows-7-what-vista-should-have-been/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 01:24:16 +0000</pubDate>
		<dc:creator>claco</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[mbp]]></category>
		<category><![CDATA[parallels]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows7]]></category>

		<guid isPermaLink="false">http://chrislaco.com/?p=65</guid>
		<description><![CDATA[Last night I downloaded Windows 7 Beta and installed it under Parallels 4 on my 17&#8243; MacBook Pro. It is without a doubt, better and faster than my Vista install and performs the same as, if not better than my &#8230; <a href="http://chrislaco.com/microsoft/windows-7-what-vista-should-have-been/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last night I downloaded Windows 7 Beta and installed it under Parallels 4 on my 17&#8243; MacBook Pro. It is without a doubt, better and faster than my Vista install and performs the same as, if not better than my XP install. Totall install took less than 15 minutes.<br />
<span id="more-65"></span><br />
This is that Vista should have been. I pray to never get a computer with Vista on it. I can&#8217;t wait to get a computer with Windows 7 on it. It&#8217;s about time Microsoft.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrislaco.com/microsoft/windows-7-what-vista-should-have-been/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
