<?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>MIKE &#187; ASP.NET</title>
	<atom:link href="http://helios.ca/category/development/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://helios.ca</link>
	<description>Just another developer blog</description>
	<lastBuildDate>Tue, 12 Jul 2011 21:35:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ASP.NET MVC Merge + Minify Javascript on the fly</title>
		<link>http://helios.ca/2011/07/12/asp-net-mvc-merge-minify-javascript-on-the-fly/</link>
		<comments>http://helios.ca/2011/07/12/asp-net-mvc-merge-minify-javascript-on-the-fly/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 21:30:33 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=183</guid>
		<description><![CDATA[According to Yahoo&#8217;s Best Practices for Speeding Up Your Web Site we should make fewer HTTP Requests. I usually like to combines my images into a single *.png file and use CSS Sprites to display the image, or merge all my JavaScripts and Styles into a single js/css file. This article is going to focus only [...]]]></description>
			<content:encoded><![CDATA[<p>According to Yahoo&#8217;s <a href="http://developer.yahoo.com/performance/rules.html">Best Practices for Speeding Up Your Web Site</a> we should make <a href="http://developer.yahoo.com/performance/rules.html#num_http">fewer HTTP Requests</a>.</p>
<p>I usually like to combines my images into a single *.png file and use CSS Sprites to display the image, or merge all my JavaScripts and Styles into a single js/css file.</p>
<p>This article is going to focus only on JavaScript and CSS minification/merging, but I might write another for images and sprites later.</p>
<p>I use this technique in all my project, it is very easy, lightweight and the best is it runs when you build your solution.</p>
<p>In this example I used:</p>
<ul>
<li>Visual Studio 2010</li>
<li>.NET 4</li>
<li>ASP.NET MVC 3</li>
<li>Yahoo YUI Compressor</li>
<li>EcmaScript.NET</li>
</ul>
<h2><strong>Step 1:</strong> Create a new MVC Project.</h2>
<p style="text-align: center;"><a href="http://helios.ca/wp-content/uploads/2011/07/1.png"><img class="size-medium wp-image-343 aligncenter" title="Create MVC Project" src="http://helios.ca/wp-content/uploads/2011/07/1-300x207.png" alt="" width="300" height="207" /></a></p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://helios.ca/wp-content/uploads/2011/07/2.png"><img class="size-medium wp-image-344 aligncenter" title="MVC Project Settings" src="http://helios.ca/wp-content/uploads/2011/07/2-300x269.png" alt="" width="300" height="269" /></a></p>
<h2>Step 2: Create some CSS and JS files.</h2>
<p>In this case I simply split the Site.css that comes with MVC into many files and added a Site.js files that simply does on alert on document ready.</p>
<p style="text-align: center;"><a href="http://helios.ca/wp-content/uploads/2011/07/3.png"><img class="size-full wp-image-345 aligncenter" title="Add some JS and CSS files" src="http://helios.ca/wp-content/uploads/2011/07/3.png" alt="" width="233" height="575" /></a></p>
<h2>Step 3: Modify the MasterPage (_Layout.cshtml) to reference the right files depending on the solution running in Debug or Release.</h2>
<h2><a href="http://helios.ca/wp-content/uploads/2011/07/4.png"><img class="aligncenter size-full wp-image-346" title="MasterPage modifications" src="http://helios.ca/wp-content/uploads/2011/07/4.png" alt="" width="742" height="352" /></a>Step4: Add the EcmacScript.NET and Yahoo.UI.Compressor binariesfrom the example file on Codeplex).</h2>
<h2><a href="http://helios.ca/wp-content/uploads/2011/07/5.png"><img class="aligncenter size-full wp-image-347" title="Add Binaries" src="http://helios.ca/wp-content/uploads/2011/07/5.png" alt="" width="221" height="71" /></a></h2>
<h2>Step 5: Create MSBuild.xml file &#8211; start from Codeplex example</h2>
<pre class="xml" name="code">
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
    <UsingTask
        TaskName="CompressorTask"
        AssemblyFile="Yahoo.Yui.Compressor.dll" />

    <PropertyGroup>
        <CssOutputFile Condition=" '$(CssOutputFile)'=='' ">
            ../AssetsMinification/Content/AssetsMinification.css
        </CssOutputFile>
        <JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">
            ../AssetsMinification/Scripts/AssetsMinification.js
        </JavaScriptOutputFile>
    </PropertyGroup>

    <Target Name="MyTaskTarget">

        <ItemGroup>
            <CssFiles Include="../AssetsMinification/Content/Reset.css"/>
            <CssFiles Include="../AssetsMinification/Content/Site.css"/>
            <CssFiles Include="../AssetsMinification/Content/Text.css"/>
            <CssFiles Include="../AssetsMinification/Content/Forms.css"/>
            <CssFiles Include="../AssetsMinification/Content/Tables.css"/>
            <CssFiles Include="../AssetsMinification/Content/Menu.css"/>

            <JavaScriptFiles Include="../AssetsMinification/Scripts/jquery-1.5.1.js"/>
            <JavaScriptFiles Include="../AssetsMinification/Scripts/modernizr-1.7.js"/>
            <JavaScriptFiles Include="../AssetsMinification/Scripts/Site.js"/>
        </ItemGroup>

        <CompressorTask
            CssFiles="@(CssFiles)"
            DeleteCssFiles="false"
            CssOutputFile="$(CssOutputFile)"
            CssCompressionType="YuiStockCompression"
            JavaScriptFiles="@(JavaScriptFiles)"
            ObfuscateJavaScript="True"
            PreserveAllSemicolons="False"
            DisableOptimizations="Nope"
            EncodingType="Default"
            DeleteJavaScriptFiles="false"
            LineBreakPosition="-1"
            JavaScriptOutputFile="$(JavaScriptOutputFile)"
            LoggingType="ALittleBit"
            ThreadCulture="en-CA"
            IsEvalIgnored="false"
            />
    </Target>
</Project>
</pre>
<h2>Step 5: Run It in release mode</h2>
<p>That&#8217;s it! </p>
<p><a href="http://www.chambaud.com/dump/beta/AssetsMinification.zip">Here&#8217;s the code.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2011/07/12/asp-net-mvc-merge-minify-javascript-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC 2 &#8211; Linking between Areas</title>
		<link>http://helios.ca/2010/06/10/asp-net-mvc-2-linking-between-areas/</link>
		<comments>http://helios.ca/2010/06/10/asp-net-mvc-2-linking-between-areas/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 15:02:37 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=267</guid>
		<description><![CDATA[If you&#8217;ve been playing with MVC 2 you might be wondering how to make ActionLinks between areas. I know it took me a good half hour to figure out! Here it is: Html.ActionLink("Display Text", "Action", "Controller", new { area = "Area" }, null); I hope it helps someone!]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been playing with MVC 2 you might be wondering how to make ActionLinks between areas. I know it took me a good half hour to figure out!</p>
<p>Here it is:</p>
<pre class="csharp" name="code">
Html.ActionLink("Display Text", "Action", "Controller", new { area = "Area" }, null);
</pre>
<p>I hope it helps someone!</p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2010/06/10/asp-net-mvc-2-linking-between-areas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC 2 Model Validation With Localization</title>
		<link>http://helios.ca/2010/02/17/asp-net-mvc-2-model-validation-with-localization/</link>
		<comments>http://helios.ca/2010/02/17/asp-net-mvc-2-model-validation-with-localization/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 17:35:03 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=226</guid>
		<description><![CDATA[So yesterday I posted about MVC 2 Model Validation. And today I&#8217;m going to do the same thing, but I&#8217;m going to Localize those ErrorMessage. In this post I&#8217;ll not be using the SetCulture Attribute from ASP.NET MVC And Localization. Instead I&#8217;ll be using the auto-culture feature of ASP.NET which will be explained here; note [...]]]></description>
			<content:encoded><![CDATA[<p>So yesterday I posted about <a href="http://helios.ca/2010/02/15/asp-net-mvc-2-model-validation/">MVC 2 Model Validation</a>. And today I&#8217;m going to do the same thing, but I&#8217;m going to Localize those ErrorMessage.</p>
<p>In this post I&#8217;ll not be using the SetCulture Attribute from <a href="http://helios.ca/2009/05/27/aspnet-mvc-and-localization/">ASP.NET MVC And Localization</a>. Instead I&#8217;ll be using the auto-culture feature of ASP.NET which will be explained here; note you could achieve the same thing with the SetCulture Attribute. </p>
<p>Obviously, we&#8217;ll start by creating a new ASP.NET MVC 2 Web Application. I did not create a Test Project for this&#8230;<br />
<a href="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-35-28-AM1.png"><img src="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-35-28-AM1.png" alt="" title="2-17-2010 11-35-28 AM" width="512" height="372" class="aligncenter size-full wp-image-242" /></a></p>
<p>Then we need to setup proper Globalization configuration in our project. For this we&#8217;ll use the Auto-Culture features of ASP.NET. Open up the Web.Config and add this line.</p>
<pre class="xml" name="code">
<configuration>
    ....
    <system.web>
        ....
        <globalization enableClientBasedCulture="true" culture="auto" uiCulture="auto"/>
    </system.web>
    ....
</configuration>
</pre>
<p>Lets make sure the Globalization works.</p>
<p>First, we&#8217;ll create the App_GlobalResources folder and add 2 resources files to it; <strong>Global.resx</strong> and <strong>Global.fr.resx</strong>. Also add some Resources to this files.<br />
<a href="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-40-17-AM1.png"><img src="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-40-17-AM1.png" alt="" title="2-17-2010 11-40-17 AM" width="520" height="156" class="aligncenter size-full wp-image-246" /></a></p>
<p>Well also need to make sure that these Resources files do not have Internal properties, but Public properties and also make it an embedded resources. To do this we need to click the <strong>Global.resx</strong> file, right-blick and go to <strong>properties</strong>. Set the <strong>Build Action</strong> to <strong>Embedded Resources</strong> and the <strong>Custom Tool</strong> to <strong>PublicResXFileCodeGenerator</strong>. </p>
<p><a href="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-12-10-37-PM.png"><img src="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-12-10-37-PM.png" alt="" title="2-17-2010 12-10-37 PM" width="415" height="158" class="aligncenter size-full wp-image-238" /></a></p>
<p>Now we&#8217;ll change some hard-coded text to Resources. I simply opened up the HomeController and changed the Index action&#8230;</p>
<pre class="csharp" name="code">
public ActionResult Index()
{
    ViewData["Message"] = Resources.Global.Welcome;

    return View();
}
</pre>
<p>Just try the application and make sure it works properly.</p>
<p><a href="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-45-27-AM.png"><img src="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-45-27-AM.png" alt="" title="2-17-2010 11-45-27 AM" width="492" height="268" class="aligncenter size-full wp-image-232" /></a></p>
<p><a href="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-45-53-AM.png"><img src="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-45-53-AM.png" alt="" title="2-17-2010 11-45-53 AM" width="493" height="268" class="aligncenter size-full wp-image-233" /></a></p>
<p>So now we know that our Localization works, but that&#8217;s not what this post is about is it&#8230; What we want is to localize the Error Messages in our Model! So lets make a test model with some validation attributes! </p>
<p>Notice that I&#8217;m not using <strong>ErrorMessage</strong> anymore, instead I&#8217;m using <strong>ErrorMessageResourceType</strong> and <strong>ErrorMessageResourceName</strong>.</p>
<pre class="csharp" name="code">
public class Test
{
    // StringLength
    [StringLength(5, ErrorMessageResourceType = typeof(Global), ErrorMessageResourceName = "StringLength")]
    public string StringLength { get; set; }

    // Required
    [Required(ErrorMessageResourceType = typeof(Global), ErrorMessageResourceName = "Required")]
    public string Required { get; set; }

    // Required and StringLength
    [Required(ErrorMessageResourceType = typeof(Global), ErrorMessageResourceName = "Required")]
    [StringLength(5, ErrorMessageResourceType = typeof(Global), ErrorMessageResourceName = "StringLength")]
    public string Combos { get; set; }

    // Range Attribute
    [Range(1, 31, ErrorMessageResourceType = typeof(Global), ErrorMessageResourceName = "Range")]
    public int Range { get; set; }

    // RegularExpression Attribute
    [RegularExpression(@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$", ErrorMessageResourceType = typeof(Global), ErrorMessageResourceName = "Email")]
    public string Regex { get; set; }

    // Custom Regular Expression EmailAttribute
    [Email(ErrorMessageResourceType = typeof(Global), ErrorMessageResourceName = "Email")]
    public string Email { get; set; }
}
</pre>
<p>So that&#8217;s it for the model, now we need a Controller and a View for that.</p>
<pre class="csharp" name="code">
[HttpGet]
public ActionResult Create()
{
   var t = new Test();
   return View(t);
}

[HttpPost]
public ActionResult Create(Test t)
{
    if (ModelState.IsValid)
    {
        // If it's valid redirect to success page, or in my case the Home page since I have nothing else...
        return Redirect("/");
    }
    return View(t);
}
</pre>
<p>For the view, just right click on either Create and click Add View&#8230;<br />
<a href="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-57-52-AM.png"><img src="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-11-57-52-AM.png" alt="" title="2-17-2010 11-57-52 AM" width="382" height="384" class="aligncenter size-full wp-image-237" /></a></p>
<p>We don&#8217;t need to change anything to the view so I&#8217;m not going to go into details on this one&#8230; Beside I&#8217;ll post the Source Code when I&#8217;m done..</p>
<p>Here&#8217;s the final result, with my browser set to French.<br />
<a href="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-12-23-09-PM.png"><img src="http://helios.ca/wp-content/uploads/2010/02/2-17-2010-12-23-09-PM.png" alt="" title="2-17-2010 12-23-09 PM" width="630" height="706" class="aligncenter size-full wp-image-253" /></a></p>
<p>It&#8217;s my first strike at this so if you have any comments or suggestion feel free to share it with us in the comment section!</p>
<p>Here&#8217;s the <a href='http://helios.ca/wp-content/uploads/2010/02/MvcModelValidationLocalized.zip'>Source Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2010/02/17/asp-net-mvc-2-model-validation-with-localization/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC 2 Model Validation</title>
		<link>http://helios.ca/2010/02/15/asp-net-mvc-2-model-validation/</link>
		<comments>http://helios.ca/2010/02/15/asp-net-mvc-2-model-validation/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 16:40:59 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=213</guid>
		<description><![CDATA[In projects I usually work on, we always use a data validation framework. But now in ASP.NET MVC 2 you can do it just as you would using a framework. You need to write your model with the proper validation attributes. using System; using System.ComponentModel.DataAnnotations; namespace FunWithMvc2RC2 { public class Test { // StringLenght [StringLength(5, [...]]]></description>
			<content:encoded><![CDATA[<p>In projects I usually work on, we always use a data validation framework. But now in ASP.NET MVC 2 you can do it just as you would using a framework. </p>
<p>You need to write your model with the proper validation attributes.</p>
<pre class="csharp" name="code">
using System;
using System.ComponentModel.DataAnnotations;

namespace FunWithMvc2RC2
{
    public class Test
    {
        // StringLenght
        [StringLength(5, ErrorMessage = "Maximum 25 Characters")]
        public string StringLength { get; set; }

        // Required
        [Required(ErrorMessage = "Required Field")]
        public string Required { get; set; }

        // Required and StringLenght
        [Required(ErrorMessage = "Required Field")]
        [StringLength(5, ErrorMessage = "Maximum 25 Characters")]
        public string Combos { get; set; }

        // Range Attribute
        [Range(1, 31, ErrorMessage = "Minimum 1; Maximum 31")]
        public int Range { get; set; }

        // RegularExpression Attribute
        [RegularExpression(@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$", ErrorMessage = "Invalid Email Address")]
        public string Regex { get; set; }

        // Custom Regular Expression EmailAttribute
        [Email(ErrorMessage = "Email Validation")]
        public string Email { get; set; }
    }
}
</pre>
<p>This will give you something like this:<br />
<a href="http://helios.ca/wp-content/uploads/2010/02/test1.jpg"><img src="http://helios.ca/wp-content/uploads/2010/02/test1.jpg" alt="" title="test" width="522" height="630" class="aligncenter size-full wp-image-220" /></a></p>
<p>And to make the Email Attribute you simply make a new class, which inherits RegularExpressionAttribute and then send the constructor an Email Address Regex! It&#8217;s this simple. You could do the same for any other Regular Expression based validation. Just Make sure you call your class &#8211; SomethingAttribute. </p>
<pre class="csharp" name="code">
using System;
using System.ComponentModel.DataAnnotations;

namespace FunWithMvc2RC2
{
    public class EmailAttribute : RegularExpressionAttribute
    {
        public EmailAttribute() :
            base(@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$") {}
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2010/02/15/asp-net-mvc-2-model-validation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC RSS Feed Action Result</title>
		<link>http://helios.ca/2009/09/22/asp-net-mvc-rss-feed-action-result/</link>
		<comments>http://helios.ca/2009/09/22/asp-net-mvc-rss-feed-action-result/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 22:17:35 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=180</guid>
		<description><![CDATA[ASP.NET MVC ships with a few ActionResult but lacks an RSS Feed ActionResult. I required one for a small project at work, so I started looking on the web if there was something interesting before coding my own. Well the googling was successful! I found a nice piece of code by Guy Burstein. If you [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET MVC ships with a few ActionResult but lacks an RSS Feed ActionResult. I required one for a small project at work, so I started looking on the web if there was something interesting before coding my own. Well the googling was successful! I found a nice piece of code by <a href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2009/01/11/asp-net-mvc-rss-feed-action-result.aspx">Guy Burstein. </a></p>
<p>If you need such an ActionResult in your application, I would recommend you to read his <a href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2009/01/11/asp-net-mvc-rss-feed-action-result.aspx">article </a>first!</p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2009/09/22/asp-net-mvc-rss-feed-action-result/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC Extension Methods of UrlHelper</title>
		<link>http://helios.ca/2009/09/21/asp-net-mvc-extension-methods-of-urlhelper/</link>
		<comments>http://helios.ca/2009/09/21/asp-net-mvc-extension-methods-of-urlhelper/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 01:31:08 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=170</guid>
		<description><![CDATA[How to create ASP.NET MVC Extensions Methods of UrlHelper]]></description>
			<content:encoded><![CDATA[<p>I think this is kind of obvious, but I guess it might not be for everyone because I&#8217;ve seen some code where people do not use this! URL Helpers are really easy to setup, it takes only a few minutes and will probably save you a lot of massive Search &amp; Replace in the future!</p>
<pre class="csharp" name="code">public static string Image(this UrlHelper helper, string fileName)
{
    return helper.Content("~/Content/Images/" + fileName));
}

public static string Stylesheet(this UrlHelper helper, string fileName)
{
    return helper.Content("~/Content/Stylesheets/" + fileName);
}

public static string Script(this UrlHelper helper, string fileName)
{
    return helper.Content("~/Content/Scripts/" + fileName);
}</pre>
<p>So instead of doing this:</p>
<pre class="csharp" name="code">&lt;link href="../../../Content/StyleSheets/Main.css" rel="stylesheet" type="text/css" /&gt;</pre>
<p>You can do this:</p>
<pre class="csharp" name="code">&lt;link href="&lt;%= Url.Stylesheet("Main.css")%&gt;" rel="stylesheet" type="text/css" /&gt;</pre>
<p>These are just 3 common examples, you should do the same thing for things you use a lot.</p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2009/09/21/asp-net-mvc-extension-methods-of-urlhelper/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC V2 Preview 1 Released!!!</title>
		<link>http://helios.ca/2009/08/01/asp-net-mvc-v2-preview-1-released/</link>
		<comments>http://helios.ca/2009/08/01/asp-net-mvc-v2-preview-1-released/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 16:35:18 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=164</guid>
		<description><![CDATA[The ASP.NET team just released ASP.NET MVC Version 2 Preview 1.  You can grab it here. Scott Guthrie wrote a nice article about it.]]></description>
			<content:encoded><![CDATA[<p>The ASP.NET team just released  ASP.NET MVC Version 2 Preview 1.  You can grab it <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=d34f9eaa-fcbe-4e20-b2fd-a9a03de7d6dd#tm" target="_blank">here</a>.</p>
<p><a href="http://weblogs.asp.net/scottgu">Scott Guthrie</a> wrote a nice <a href="http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx"></a><a href="http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx">article</a> about it.<a href="http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2009/08/01/asp-net-mvc-v2-preview-1-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Did You Know: &#8220;App_Offline.htm&#8221; Takes IIS Website Offline</title>
		<link>http://helios.ca/2009/07/01/did-you-know-app_offline-htm-takes-iis-website-offline/</link>
		<comments>http://helios.ca/2009/07/01/did-you-know-app_offline-htm-takes-iis-website-offline/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 17:36:10 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=151</guid>
		<description><![CDATA[Just drop an App_Offline.htm in the root of your website all requests will automatically be redirected to this file! This is neat! Found it on ScottGu&#8217;s and Erik Porter&#8217;s blogs]]></description>
			<content:encoded><![CDATA[<p>Just drop an App_Offline.htm in the root of your website all requests will automatically be redirected to this file! This is neat!</p>
<p>Found it on <a href="http://weblogs.asp.net/scottgu/archive/2005/10/06/426755.aspx">ScottGu&#8217;s</a> and <a href="http://weblogs.asp.net/eporter/archive/2005/10/05/426708.aspx">Erik Porter&#8217;s</a> blogs</p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2009/07/01/did-you-know-app_offline-htm-takes-iis-website-offline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deploying ASP.NET MVC Application under IIS6</title>
		<link>http://helios.ca/2009/06/23/deploying-asp-net-mvc-application-under-iis6/</link>
		<comments>http://helios.ca/2009/06/23/deploying-asp-net-mvc-application-under-iis6/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 11:43:30 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=138</guid>
		<description><![CDATA[When deploying an ASP.NET MVC application under Windows Server 2003 and IIS6 (and Windows Server 2008 Classic Mode), you&#8217;ll get 404 page not found error on every page, except the index of the site. This is because IIS6 doesn&#8217;t not support routing. There are many solutions to fix this, I&#8217;ll just explain my favorite, which [...]]]></description>
			<content:encoded><![CDATA[<p>When deploying an ASP.NET MVC application under Windows Server 2003 and IIS6 (and Windows Server 2008 Classic Mode), you&#8217;ll get 404 page not found error on every page, except the index of the site. This is because IIS6 doesn&#8217;t not support routing.</p>
<p>There are many solutions to fix this, I&#8217;ll just explain my favorite, which is extension-less url.</p>
<p>So lets show IIS6 how to handle extension-less URL. For this, we&#8217;ll use the Wildcard Mapping feature.</p>
<ul>
<li>Open Internet Information Services (IIS) Manager. (run inetmgr)</li>
<li><strong>Right Click » Pro</strong><strong>perties</strong> on your website.<br />
<img class="alignnone size-full wp-image-140" title="1" src="http://helios.ca/wp-content/uploads/2009/06/1.png" alt="1" width="485" height="341" /></li>
<li>Open the <strong>Home Directory</strong> tab.</li>
<li>Click on the <strong>Configuration </strong>button.</li>
<li>Open the <strong>Mappings</strong> tab of the Application Configuration window.<img class="alignnone size-full wp-image-142" title="2" src="http://helios.ca/wp-content/uploads/2009/06/21.png" alt="2" width="292" height="297" /></li>
<li>In the <strong>Wildcard application maps</strong> section, click on the <strong>Insert </strong>button.</li>
<li>Browse to %windir%\Microsoft.NET\Framework\v2.0.50727\<strong>aspnet_isapi.dll.</strong></li>
<li><strong>uncheck </strong>&#8220;Verify that file exists&#8221;.<br />
<img class="alignnone size-full wp-image-143" title="3" src="http://helios.ca/wp-content/uploads/2009/06/3.png" alt="3" width="428" height="127" /></li>
<li>That&#8217;s it! Now try your ASP.NET MVC Application it should work nicely!</li>
</ul>
<p><a href="http://haacked.com">Phil Haack</a> has a very good article about this matter and also explains other solution. You should definitly<a href="http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx"> read it</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2009/06/23/deploying-asp-net-mvc-application-under-iis6/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC Cascading DropDownList with jQuery</title>
		<link>http://helios.ca/2009/05/30/aspnet-mvc-cascading-dropdownlist-with-jquery/</link>
		<comments>http://helios.ca/2009/05/30/aspnet-mvc-cascading-dropdownlist-with-jquery/#comments</comments>
		<pubDate>Sat, 30 May 2009 22:50:00 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[Developement]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://helios.ca/?p=64</guid>
		<description><![CDATA[Here a simple example of cascading drop down list in ASP.NET MVC with jQuery. First you need models. I chosed to do this example using a Country and State dropdown, so I&#8217;m going to build to Models (Country and State) with a little bit of fake data. Lets start with the Country Model and Fake [...]]]></description>
			<content:encoded><![CDATA[<p>Here a simple example of cascading drop down list in ASP.NET MVC with jQuery.</p>
<p>First you need models. I chosed to do this example using a Country and State dropdown, so I&#8217;m going to build to Models (Country and State) with a little bit of fake data.</p>
<p>Lets start with the Country Model and Fake Data</p>
<pre name="code" class="csharp">using System.Collections.Generic;
using System.Linq;

namespace CascadingDDLjQueryDemo.Models
{
    public class Country
    {
        public string CountryCode { get; set; }
        public string CountryName { get; set; }

        public static IQueryable<Country> GetCountries()
        {
            return new List<Country>
            {
                new Country {
                    CountryCode = "CA",
                    CountryName = "Canada"
                },
                new Country{
                    CountryCode = "US",
                    CountryName = "United-States"
                }
            }.AsQueryable();
        }
    }
}</pre>
<p>And now the State Model and Fake Data</p>
<pre name="code" class="csharp">using System.Collections.Generic;
using System.Linq;

namespace CascadingDDLjQueryDemo.Models
{
    public class State
    {
        public string CountryCode { get; set; }
        public int StateID { get; set; }
        public string StateName { get; set; }

        public static IQueryable<State> GetStates()
        {
            return new List<State>
            {
                new State
                    {
                        CountryCode = "CA",
                        StateID=1,
                        StateName = "Ontario"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=2,
                        StateName = "Quebec"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=3,
                        StateName = "Nova Scotia"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=4,
                        StateName = "New Brunswick"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=5,
                        StateName = "Manitoba"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=6,
                        StateName = "British Columbia"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=7,
                        StateName = "Prince Edward Island"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=8,
                        StateName = "Saskatchewan"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=9,
                        StateName = "Alberta"
                    },
                new State
                    {
                        CountryCode = "CA",
                        StateID=10,
                        StateName = "Newfoundland and Labrador"
                    },
                new State
                    {
                        CountryCode = "US",
                        StateID=11,
                        StateName = "New-York"
                    },
                new State
                    {
                        CountryCode = "US",
                        StateID=12,
                        StateName = "California"
                    },
                new State
                    {
                        CountryCode = "US",
                        StateID=13,
                        StateName = "Washington"
                    },
                new State
                    {
                        CountryCode = "US",
                        StateID=14,
                        StateName = "Vermont"
                    }
            }.AsQueryable();
        }
    }
}</pre>
<p>We can now add List methods in the controller. I chosed to return both Json and View so I could decide to make a page CountryList and use the same method.</p>
<pre name="code" class="csharp">using System.Linq;
using System.Web.Mvc;
using CascadingDDLjQueryDemo.Models;

namespace CascadingDDLjQueryDemo.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult CountryList()
        {
            IQueryable countries =
                Country.GetCountries();

            if(HttpContext.Request.IsAjaxRequest())
                return Json(new SelectList(
                                countries,
                                "CountryCode",
                                "CountryName")
                            );

            return View(countries);
        }

        public ActionResult StateList(string CountryCode)
        {
            IQueryable states = State.GetStates()
                .Where(x =&gt; x.CountryCode == CountryCode);

            if (HttpContext.Request.IsAjaxRequest())
                return Json(new SelectList(
                                states,
                                "StateID",
                                "StateName")
                            );

            return View(states);
        }
    }
}</pre>
<p>And now we require Routes to access this data</p>
<pre name="code" class="csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace CascadingDDLjQueryDemo
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode,
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "StatesList",
                "Home/States/List/{CountryCode}",
                new { controller = "Home", action = "StateList", CountryCode = "" }
            );

            routes.MapRoute(
                "CountriesList",
                "Home/Countries/List",
                new { controller = "Home", action = "CountryList" }
            );

            routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = "" }
            );

        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
        }
    }
}</pre>
<p>The Javavascript</p>
<pre name="code" class="javascript">$(function() {
        $.getJSON("/Home/Countries/List", function(data) {
            var items = "
<option>---------------------</option>

";
            $.each(data, function(i, country) {
                items += "
<option value='"+country.Value+"'>" + country.Text + "</option>

";
            });
            $("#Countries").html(items);
        });

        $("#Countries").change(function() {
            $.getJSON("/Home/States/List/" + $("#Countries &gt; option:selected").attr("value"), function(data) {
                var items = "
<option>---------------------</option>

";
                $.each(data, function(i, state) {
                    items += "
<option value='"+state.Value+"'>" + state.Text + "</option>

";
                });
                $("#States").html(items);
            });
        });
    });</pre>
<p>And finally, the Index View.</p>
<pre name="code" class="xhtml">
<h2>ASP.NET MVC Cascading DropDownList using jQuery</h2>

<label for="Countries">Countries</label>
<select id="Countries" name="Countries"></select>

        <label for="States">States</label>
<select id="States" name="States"></select>
</pre>
<p>You can find the <a href="http://www.helios.ca/wp-content/uploads/2009/05/CascadingDropDownListJquery.zip">source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://helios.ca/2009/05/30/aspnet-mvc-cascading-dropdownlist-with-jquery/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

