<?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>Zenji Web Development &#187; Software Development</title>
	<atom:link href="http://www.zenjiwebworks.com/category/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zenjiwebworks.com</link>
	<description>Website development and consultancy</description>
	<lastBuildDate>Fri, 25 Sep 2009 08:10:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone Blogging</title>
		<link>http://www.zenjiwebworks.com/2009/03/12/iphone-blogging/</link>
		<comments>http://www.zenjiwebworks.com/2009/03/12/iphone-blogging/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 18:32:20 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2009/03/12/iphone-blogging/</guid>
		<description><![CDATA[I only just noticed that there&#8217;s a blogging app for Wordpress on the iPhone. It happily gets around the problem with Safari not allowing image uploads. 

]]></description>
			<content:encoded><![CDATA[<p>I only just noticed that there&#8217;s a blogging app for Wordpress on the iPhone. It happily gets around the problem with Safari not allowing image uploads. </p>
<p><a href="http://www.zenjiwebworks.com/wp-content/uploads/2009/03/p-640-480-018d9434-0e97-48c5-ace3-02583bcefe94.jpeg"><img src="http://www.zenjiwebworks.com/wp-content/uploads/2009/03/p-640-480-018d9434-0e97-48c5-ace3-02583bcefe94.jpeg" alt="" width="225" height="300" class="alignnone size-full wp-image-364" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2009/03/12/iphone-blogging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC ActionFilters and Response.Redirect</title>
		<link>http://www.zenjiwebworks.com/2008/12/19/aspnet-mvc-actionfilters-and-responseredirect/</link>
		<comments>http://www.zenjiwebworks.com/2008/12/19/aspnet-mvc-actionfilters-and-responseredirect/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 16:28:53 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Gotchas]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2008/12/19/aspnet-mvc-actionfilters-and-responseredirect/</guid>
		<description><![CDATA[There is an issue with using the following code in an action filter:



filterContext.HttpContext.Response.Redirect&#40;loginUrl, true&#41;;



which is a bit of code quite common in an authentication filter. The problem is it will throw a ThreadAbortException as soon as you put your code on a live site resulting in the error page for anyone who is not logged [...]]]></description>
			<content:encoded><![CDATA[<p>There is an issue with using the following code in an action filter:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">filterContext.<span class="me1">HttpContext</span>.<span class="me1">Response</span>.<span class="me1">Redirect</span><span class="br0">&#40;</span>loginUrl, <span class="kw2">true</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>which is a bit of code quite common in an authentication filter. The problem is it will throw a ThreadAbortException as soon as you put your code on a live site resulting in the error page for anyone who is not logged in. This is probably not what you want since you are attempting to redirect them to the login page.</p>
<p>Now it is a little unfair to say that it&#8217;s an issue because that is the intended functionality. But it doesn&#8217;t fit well with MVC controllers, especially since Microsoft&#8217;s official suggestion is to set the endResponse flag to false. That is just downright misleading since your controller action (which the filter just decided you can&#8217;t access) is still executed after the filter fails authentication &#8211; resulting in the action code being executed anyway whilst you see the login screen on the browser and assume it all went swimmingly! Meanwhile those files that this user shouldn&#8217;t have access to got deleted.</p>
<p>Yeah, that&#8217;s what I just did during testing whilst proving to myself that you can&#8217;t fake the URL as a non-registered user. Imagine my surprise. It&#8217;s true that the chances of a malicious user actually working out the URL might be low, but that&#8217;s no reason to leave the door open.</p>
<p>Oh, and your unit tests probably won&#8217;t catch this because the filters don&#8217;t get executed by the unit tests. But I digress&#8230;</p>
<p>To cut a long story short, this bit of code in your base controller (assuming you have one, otherwise stick in in all of the controllers) will prevent the issue:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">protected override <span class="kw4">void</span> OnException<span class="br0">&#40;</span>ExceptionContext filterContext<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>filterContext.<span class="me1">Exception</span> is ThreadAbortException<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; filterContext.<span class="me1">ExceptionHandled</span> = <span class="kw2">true</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2008/12/19/aspnet-mvc-actionfilters-and-responseredirect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maximum Request Length Exceeded</title>
		<link>http://www.zenjiwebworks.com/2008/12/11/maximum-request-length-exceeded/</link>
		<comments>http://www.zenjiwebworks.com/2008/12/11/maximum-request-length-exceeded/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 08:52:52 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2008/12/11/maximum-request-length-exceeded/</guid>
		<description><![CDATA[It&#8217;s hard to believe how badly this is handled in IIS. Admittedly I&#8217;ve only tried it in IIS 6, but I see no evidence that it gets any better in IIS 7.
So here&#8217;s the problem &#8211; you create a website that allows the upload of images (or any file types for that matter). It&#8217;s very [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s hard to believe how badly this is handled in IIS. Admittedly I&#8217;ve only tried it in IIS 6, but I see no evidence that it gets any better in IIS 7.</p>
<p>So here&#8217;s the problem &#8211; you create a website that allows the upload of images (or any file types for that matter). It&#8217;s very likely you&#8217;re going to want to limit the size of those uploads or you&#8217;ll end up in a world of pain when your users go and use up all your disk space. By default IIS allows upload sizes of 4Mb which is ample for image purposes. However, if someone uploads a file above that size you&#8217;re likely to want to notify them by telling them gently they&#8217;re an idiot for not reading the note above the file input field and then allow them to reselect a file.</p>
<p>But you can&#8217;t because the requests never gets to your page. IIS simply drops the request and seems to respond with nothing at all. That leaves the user looking at a &#8216;Web site could not be found&#8217; error, which is misleading and just plain wrong.<br />
<span id="more-39"></span></p>
<p>And this is the situation I found myself in. Simply put, you can&#8217;t catch the HttpException in your code and recover gracefully. Unfortunately the vast majority of people out there believe the answer is to increase the maxRequestLength in web.config. How can that be considered a solution? It&#8217;s like saying the way to deal with traffic congestion is to double the size of every road. Someone, somewhere will then try and upload a file that is even bigger and the problem repeats itself.</p>
<p>I spent a long time looking for a solution and eventually came across a little trick which you can pull in your Global.asax:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">protected <span class="kw4">void</span> Application_BeginRequest<span class="br0">&#40;</span>Object sender, EventArgs e<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> maxRequestLength = <span class="nu0">4096000</span>; <span class="co1">// 4MB</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>Request.<span class="me1">ContentLength</span> &gt; maxRequestLength<span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; HttpApplication app = sender as HttpApplication;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; HttpContext context = app.<span class="me1">Context</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; HttpWorkerRequest wr = <span class="br0">&#40;</span>HttpWorkerRequest<span class="br0">&#41;</span><span class="br0">&#40;</span>context.<span class="me1">GetType</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">GetProperty</span><span class="br0">&#40;</span><span class="st0">&quot;WorkerRequest&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.<span class="me1">Reflection</span>.<span class="me1">BindingFlags</span>.<span class="me1">Instance</span> | System.<span class="me1">Reflection</span>.<span class="me1">BindingFlags</span>.<span class="me1">NonPublic</span><span class="br0">&#41;</span>.<span class="me1">GetValue</span><span class="br0">&#40;</span>context, <span class="kw2">null</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; byte<span class="br0">&#91;</span><span class="br0">&#93;</span> buffer;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>wr.<span class="me1">HasEntityBody</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> contentlen = Convert.<span class="me1">ToInt32</span><span class="br0">&#40;</span>wr.<span class="me1">GetKnownRequestHeader</span><span class="br0">&#40;</span>HttpWorkerRequest.<span class="me1">HeaderContentLength</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buffer = wr.<span class="me1">GetPreloadedEntityBody</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> received = buffer.<span class="me1">Length</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> totalrecv = received;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!wr.<span class="me1">IsEntireEntityBodyIsPreloaded</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buffer = new byte<span class="br0">&#91;</span><span class="nu0">65535</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span>contentlen &#8211; totalrecv &gt;= received<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; received = wr.<span class="me1">ReadEntityBody</span><span class="br0">&#40;</span>buffer, buffer.<span class="me1">Length</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalrecv += received;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; received = wr.<span class="me1">ReadEntityBody</span><span class="br0">&#40;</span>buffer, contentlen &#8211; totalrecv<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; context.<span class="me1">Response</span>.<span class="me1">Redirect</span><span class="br0">&#40;</span><span class="st0">&quot;~/Error.aspx/FileTooBig&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Thanks to <a href="http://dotnetslackers.com/Community/blogs/haissam/archive/2008/09.aspx">this guy</a> for the hard work.</p>
<p>It seems to be about the only place in the code that you can do anything about the error. What it&#8217;s actually doing is reading in the whole of the request even though it is over your maximum request size. Once the whole request has been read you are able to make a response to the calling client, in this case a redirect to an error page. It&#8217;s possible that you could take this further and carry on with the page the user originally intended to work with, catching the error and displaying it there. But I&#8217;m too burned out to try that right now and this solution works fine for me!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2008/12/11/maximum-request-length-exceeded/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Html.DropDownList in ASP.NET MVC</title>
		<link>http://www.zenjiwebworks.com/2008/12/09/using-htmldropdownlist-in-aspnet-mvc/</link>
		<comments>http://www.zenjiwebworks.com/2008/12/09/using-htmldropdownlist-in-aspnet-mvc/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 14:07:11 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2008/12/09/using-htmldropdownlist-in-aspnet-mvc/</guid>
		<description><![CDATA[This is something I think is particularly poorly documented for the MVC framework. It took me a long time Googling and, in the end, guessing in order to get it to work correctly (and it&#8217;s still not how I&#8217;d like it, but there you go). Simply put, this is the code in the Controller:



var portfolioSelect [...]]]></description>
			<content:encoded><![CDATA[<p>This is something I think is particularly poorly documented for the MVC framework. It took me a long time Googling and, in the end, guessing in order to get it to work correctly (and it&#8217;s still not how I&#8217;d like it, but there you go). Simply put, this is the code in the Controller:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">var portfolioSelect = new Dictionary&lt;string, object&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">foreach <span class="br0">&#40;</span>var portfolio in portfolioList<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; portfolioSelect.<span class="me1">Add</span><span class="br0">&#40;</span>portfolio.<span class="me1">ID</span>, portfolio.<span class="me1">Name</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">ViewData<span class="br0">&#91;</span><span class="st0">&quot;PortfolioSelectDropDownList&quot;</span><span class="br0">&#93;</span> = new SelectList<span class="br0">&#40;</span>portfolioSelect, <span class="st0">&quot;key&quot;</span>, <span class="st0">&quot;value&quot;</span>, id<span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>And this is the code in the View:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;%=Html.<span class="me1">DropDownList</span><span class="br0">&#40;</span><span class="st0">&quot;PortfolioSelectDropDownList&quot;</span><span class="br0">&#41;</span>%&gt;</div>
</li>
</ol>
</div>
<p>I know it&#8217;s still only in Beta, but I think it&#8217;s time some of the Microsoft boys tidied up their otherwise useful blogs to remove and update many incorrect usage instructions for the latest cut of the framework. After all, it&#8217;s the only documentation we have at the moment.</p>
<p>One more issue I&#8217;ve found is the name that is assigned to the resulting &lt;select&gt; tag. It&#8217;s a bit irritating as I may not want the name to be the same is the key that is used in the ViewData (which is what it uses here, i.e. &#8220;PortfolioSelectDropDownList&#8221; in my case). That messes up my typed view. The only way I&#8217;ve found around this is to use the name of the variable in my typed view for the ViewData key, e.g. &#8220;Project.PortfolioID&#8221;. The result is that I get a select list and when the form is posted back my Project object is populated with the selected value.</p>
<p>To be honest it has a certain elegance to it so it may even be the intended usage! Still seems a bit strange to me though&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2008/12/09/using-htmldropdownlist-in-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Strongly-Typed Views in ASP.NET MVC Beta</title>
		<link>http://www.zenjiwebworks.com/2008/12/05/creating-strongly-typed-views-in-aspnet-mvc-beta/</link>
		<comments>http://www.zenjiwebworks.com/2008/12/05/creating-strongly-typed-views-in-aspnet-mvc-beta/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 11:42:01 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2008/12/05/creating-strongly-typed-views-in-aspnet-mvc-beta/</guid>
		<description><![CDATA[One of the big problems with the early adoption of any framework is the documentation. No books are released yet, if they are ever going to be, and so turning to Google is your best bet. In fact it&#8217;s your only option and my own preference is using Google over books anyway.
But frameworks change during [...]]]></description>
			<content:encoded><![CDATA[<p>One of the big problems with the early adoption of any framework is the documentation. No books are released yet, if they are ever going to be, and so turning to Google is your best bet. In fact it&#8217;s your only option and my own preference is using Google over books anyway.</p>
<p>But frameworks change during development and you come across the issue that all of the top hits for your query are based on previous versions. When that previous version did it differently you&#8217;re stuck! I had this problem today when trying to create strongly-typed views. I love strongly-typed anythings, but I&#8217;m just a sucker for having a project that is more likely to work when another developer makes an edit and doesn&#8217;t bother fully checking the effects of their changes. It&#8217;s another safety net, and I&#8217;m a sucker for safety nets as well.</p>
<p>So, this is how I did it in bite-sized chunks. First the controller function:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">public ActionResult Index<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; var ContentObject = new ContentClass<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> View<span class="br0">&#40;</span>ContentModel.<span class="me1">Load</span><span class="br0">&#40;</span>ContentObject<span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Next I created a new view by right-clicking the above method (bear in mind that I&#8217;m using Visual Studio 2008) and checking the &#8216;Create a strongly-typed view&#8217; before entering the full name of the object type (ContentClass). That produces an aspx.cs which looks something like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">public partial class Index : ViewPage&lt;ContentClass&gt;</div>
</li>
</ol>
</div>
<p>So far so good, but where I really came unstuck was actually using this in the view. Turns out it&#8217;s simpler than ever. All you need to use is the ViewData.Model parameter, which is automatically typed to whatever you set the view up as previously:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;%</div>
</li>
<li class="li1">
<div class="de1">foreach <span class="br0">&#40;</span>var portfolio in ViewData.<span class="me1">Model</span>.<span class="me1">Portfolios</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">%&gt;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &lt;p&gt;&lt;%= portfolio.<span class="me1">ID</span> %&gt;&lt;/p&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;%</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">%&gt;</div>
</li>
</ol>
</div>
<p>All that I have to do now is pass that through to a UserControl. I&#8217;m assuming I can strongly-type those as well. We shall see.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2008/12/05/creating-strongly-typed-views-in-aspnet-mvc-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying ASP.NET MVC Applications</title>
		<link>http://www.zenjiwebworks.com/2008/11/28/deploying-aspnet-mvc-applications/</link>
		<comments>http://www.zenjiwebworks.com/2008/11/28/deploying-aspnet-mvc-applications/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 21:56:31 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2008/11/28/deploying-aspnet-mvc-applications/</guid>
		<description><![CDATA[Now I&#8217;m a huge fan of the ASP.NET MVC framework. So much so that I have taken to porting across applications already started using the Castle Monorail framework. Why? Well, there&#8217;s just a nice, warm, supported feeling when using a framework that is built-in to your chosen development platform.
Or at least that&#8217;s what you&#8217;d think. You [...]]]></description>
			<content:encoded><![CDATA[<p>Now I&#8217;m a huge fan of the ASP.NET MVC framework. So much so that I have taken to porting across applications already started using the Castle Monorail framework. Why? Well, there&#8217;s just a nice, warm, supported feeling when using a framework that is built-in to your chosen development platform.</p>
<p>Or at least that&#8217;s what you&#8217;d think. You know how it is &#8211; you get it all working on your lovely development machine and then once the decision has been made on where to host the final result, you upload your application and&#8230;bang&#8230;</p>
<pre>HttpException (0x80004005): The incoming request does not match any route.</pre>
<p>Oh yes, that works so well.</p>
<p>Suddenly that belief that, finally, someone has produced a framework which is so nicely integrated with your target platform comes crashing down around your head as you weep softly into your keyboard. No, ASP.NET MVC is not actually supported on anything under IIS7. Does your host offer IIS7 at the moment? I guess not.</p>
<p>Now don&#8217;t get me wrong, it does <em>work</em> on IIS6 but you have to mangle it a bit and unless you pay a fortune each month for access to your own virtual server then you&#8217;re likely to lose those pretty urls. That&#8217;s not the same as being <em>supported</em>. For those that have spent the last two hours Googling and still getting the same problem, here is the man with the answer:</p>
<p><a href="http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx">http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2008/11/28/deploying-aspnet-mvc-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The trouble with the right-alignment of input fields</title>
		<link>http://www.zenjiwebworks.com/2008/07/11/the-trouble-with-right-alignment-of-input-fields/</link>
		<comments>http://www.zenjiwebworks.com/2008/07/11/the-trouble-with-right-alignment-of-input-fields/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 10:32:31 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Gotchas]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2008/07/11/the-trouble-with-right-alignment-of-input-fields/</guid>
		<description><![CDATA[Everyone knows that when you have a text box which accepts a number, it should automatically right-align the text content. Well maybe not everyone, but accountants certainly do and if you&#8217;re writing an application for an accountant it just won&#8217;t look right unless the values are right-aligned.
Simple, I thought &#8211; text-align:right in the CSS and [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone knows that when you have a text box which accepts a number, it should automatically right-align the text content. Well maybe not everyone, but accountants certainly do and if you&#8217;re writing an application for an accountant it just won&#8217;t look right unless the values are right-aligned.</p>
<p>Simple, I thought &#8211; text-align:right in the CSS and the jobs a good &#8216;un. Well yes, you would think so. The fact of the matter is that text-align:right is only supposed to apply to block level elements (according to the CSS2 specs), although it isn&#8217;t quite implemented that way in all browsers. So, add display:block in there as well just to be on the safe side:</p>
<p>Left Align: &lt;input style=&#8221;padding: 0px; text-align: right; display: block&#8221; type=&#8221;text&#8221; /&gt;</p>
<input style="padding: 0px; text-align: right; display: block" type="text" /> Right Align: &lt;input style=&#8221;padding: 0px; display: block&#8221; type=&#8221;text&#8221; /&gt;</p>
<input style="padding: 0px; display: block" type="text" />
<p>Job done! Well, not quite if you are viewing this in Internet Explorer 7. Click in the input field which is aligned to the right and no cursor displays at all! I must be tired today because this took me ages to work out and I found no reference to it anywhere in the web. For some reason the cursor is there &#8211; it&#8217;s just off to the right a little too far. I say &#8217;some reason&#8217; when I now know that the actual reason is that the padding is set to 0px. The reason for this happens to be because it has inherited the property from other elements in my form layout, but in this example I have added it specifically. Add a little padding to the right and hey presto:</p>
<p>Left Align: &lt;input style=&#8221;padding: 0px 1px 0px 0px; text-align: right; display: block&#8221; type=&#8221;text&#8221; /&gt;</p>
<input style="padding: 0px 1px 0px 0px; text-align: right; display: block" type="text" /> Right Align: &lt;input style=&#8221;padding: 0px 1px 0px 0px; display: block&#8221; type=&#8221;text&#8221; /&gt;</p>
<input style="padding: 0px 1px 0px 0px; display: block" type="text" />
<p>That&#8217;s just strange. Zero padding displays the cursor on the left, but not the right. Except in Firefox, which just shows it correctly in either case.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2008/07/11/the-trouble-with-right-alignment-of-input-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ConfigureIIS running on systems without IIS</title>
		<link>http://www.zenjiwebworks.com/2008/04/01/configureiis-running-on-systems-without-iis/</link>
		<comments>http://www.zenjiwebworks.com/2008/04/01/configureiis-running-on-systems-without-iis/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 09:53:15 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Gotchas]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2008/04/01/configureiis-running-on-systems-without-iis/</guid>
		<description><![CDATA[These days I always seem to find myself writing installers for clients using WiX. What usually happens is I get there to find they are really struggling to maintain their current installers, more often then not in InstallShield. So I go and tell them they should try WiX since it has so many advantages over [...]]]></description>
			<content:encoded><![CDATA[<p>These days I always seem to find myself writing installers for clients using <a href="http://wix.sourceforge.net/" target="_blank">WiX</a>. What usually happens is I get there to find they are really struggling to maintain their current installers, more often then not in InstallShield. So I go and tell them they should try WiX since it has so many advantages over certain other products. For a start it&#8217;s actually maintained by several Microsoft guys and enjoys a big support community. Also since the source code is written in XML it is much easier to check in to source control and maintain.</p>
<p>Anyway, to cut a long story short, my evangelising on the subject usually ends in the words &#8216;here you go then, write an installer for that&#8217;. And so I end up with the job yet again.</p>
<p>That&#8217;s not to say it doesn&#8217;t have its issues like so many other things in the world of software development, especially when you end up writing some monster installer that installs a web-client, web-services, windows-services and the odd database or two.</p>
<p>Today&#8217;s issue was ConfigureIIS which is a custom action executed if you are creating a &lt;WebVirtualDir&gt;. Unfortunately even if you are not installing the web component that needs IIS to be configured it will still attempt to execute ConfigureIIS which causes an error to appear if IIS is not installed. Just having a web component in your installer is enough to fire it off.</p>
<p>Looking on the WiX mailing lists it seems that it is a known issue and the only way around it currently is by modifying and recompiling the source code for WiX itself. Not a lot of fun when you just want to write an installer and it takes you away from the currently released code, which I find it is best to avoid when working for other clients.</p>
<p>However, in the process of modifying the source I found the property SKIPCONFIGUREIIS. Set this to true and it no longer runs the ConfigureIIS custom action. Obviously you need to make sure it&#8217;s only turned off for the relevant features of your installer. It&#8217;s just a shame they didn&#8217;t make it a little more widely known!</p>
<p>To be honest I could have kicked myself since I already knew of the SKIPINSTALLSQLDATA for turning off the database activity when not required. That one is a little more published though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2008/04/01/configureiis-running-on-systems-without-iis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mortgage Calculator</title>
		<link>http://www.zenjiwebworks.com/2008/02/26/mortgage-calculator/</link>
		<comments>http://www.zenjiwebworks.com/2008/02/26/mortgage-calculator/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 19:20:58 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Components]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2008/02/26/mortgage-calculator/</guid>
		<description><![CDATA[Here&#8217;s a helpful little gadget I just knocked up.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.zenjiwebworks.com/mortgagecalculator.html">Here&#8217;s a helpful little gadget</a> I just knocked up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2008/02/26/mortgage-calculator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Samba server connections on a Mac</title>
		<link>http://www.zenjiwebworks.com/2007/07/29/samba-server-connections-on-a-mac/</link>
		<comments>http://www.zenjiwebworks.com/2007/07/29/samba-server-connections-on-a-mac/#comments</comments>
		<pubDate>Sun, 29 Jul 2007 08:21:44 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Gotchas]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.zenjiwebworks.com/2007/07/29/samba-server-connections-on-a-mac/</guid>
		<description><![CDATA[Since I got the Mac a couple of months ago there is one thing that keeps bugging me; connecting to my server is not particularly reliable. Dropped connections seemed to be pretty much guaranteed half way through a job that involves anything more than a couple of Mb of data. Since I tend to use [...]]]></description>
			<content:encoded><![CDATA[<p>Since I got the Mac a couple of months ago there is one thing that keeps bugging me; connecting to my server is not particularly reliable. Dropped connections seemed to be pretty much guaranteed half way through a job that involves anything more than a couple of Mb of data. Since I tend to use the server for automated backups of my other machines it just hasn&#8217;t been happening for the Mac. Slowly I&#8217;ve got more and more concerned about having no regular backups.</p>
<p>A chance comment I came across whilst Googling for something else seems to have cleared up the issue. It seems my technique of using the Network utility in the Finder was the main issue. It is certainly the simplest option and most people seem to use it for that very reason. The trouble is it doesn&#8217;t always get the protocol right. You can check this by creating a connection to your server (in the finder choose Network and then browse to your server and connect to a share), selecting the new connection and then checking the info (Apple key and I). Mine shows up as:</p>
<p>cifs://my_server/backup</p>
<p>Since my Linux server uses Samba for the network shares it&#8217;s far better to connect using the Samba protocol:</p>
<p>smb://my_server/backup</p>
<p>The easiest way to set this up is through the &#8216;Connect to Server&#8217; utility in the Finder. This also stores your server connections for easy future access. You should be able to simply type the connection string in and then connect at will. Hopefully you&#8217;ll see a much more stable connection in future.</p>
<p>(An extra tip &#8211; once you have the connection set up you can automatically connect at login by adding it to the list in System Preferences-&gt;Accounts-&gt;Login Items)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zenjiwebworks.com/2007/07/29/samba-server-connections-on-a-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
