<?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>Martijn Boland &#187; ASP.NET MVC</title>
	<atom:link href="http://blogs.taiga.nl/martijn/tag/aspnet-mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.taiga.nl/martijn</link>
	<description>New adventures in .NET</description>
	<lastBuildDate>Tue, 27 Apr 2010 20:51:13 +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>Entity Framework 4 Code-First demo updated to Feature CTP3</title>
		<link>http://blogs.taiga.nl/martijn/2010/04/27/entity-framework-4-code-first-demo-updated-to-feature-ctp3/</link>
		<comments>http://blogs.taiga.nl/martijn/2010/04/27/entity-framework-4-code-first-demo-updated-to-feature-ctp3/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 20:51:13 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[O/R mapping]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2010/04/27/entity-framework-4-code-first-demo-updated-to-feature-ctp3/</guid>
		<description><![CDATA[The EF 4 code-first demo has been updated to reference the EF4 Feature CTP3 dll at its default location. To run the demo, you have to make sure that the you have it installed. Download the EF 4 Feature CTP3 at http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&#38;displayLang=en. Although the demo was originally developed with VS 2010 Beta 2 everything works [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/">EF 4 code-first demo</a> has been updated to reference the EF4 Feature CTP3 dll at its default location. To run the demo, you have to make sure that the you have it installed. Download the EF 4 Feature CTP3 at <a title="http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&amp;displayLang=en" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&amp;displayLang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&amp;displayLang=en</a>.</p>
<p>Although the demo was originally developed with VS 2010 Beta 2 everything works perfectly fine on VS 2010 RTM.</p>
<p>You can find the demo sources at github: <a title="http://github.com/martijnboland/EF4-codeonly-demo" href="http://github.com/martijnboland/EF4-codeonly-demo">http://github.com/martijnboland/EF4-codeonly-demo</a> where it’s also possible to download the sources all at once.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2010/04/27/entity-framework-4-code-first-demo-updated-to-feature-ctp3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paging demo for ASP.NET MVC 2</title>
		<link>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/</link>
		<comments>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:27:58 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Area]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/</guid>
		<description><![CDATA[During work, I discovered that the pager that I created a while ago didn’t work properly when using ASP.NET MVC2 area’s. The links that were generated didn’t count for the current area that the controller and views were in, resulting in wrong urls. Luckily the ASP.NET MVC team also ran into this issue and created [...]]]></description>
			<content:encoded><![CDATA[<p>During work, I discovered that the <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/" target="_blank">pager that I created a while ago</a> didn’t work properly when using ASP.NET MVC2 area’s. The links that were generated didn’t count for the current area that the controller and views were in, resulting in wrong urls. Luckily the ASP.NET MVC team also ran into this issue and created an GetVirtualPathForArea() extension method on RouteCollection. Calling this one, instead of GetVirtualPath() made things work properly in area’s.</p>
<p>You can get the code for ASP.NET MVC 2 at <a title="http://github.com/martijnboland/MvcPaging/tree/mvc2" href="http://github.com/martijnboland/MvcPaging/tree/mvc2">http://github.com/martijnboland/MvcPaging/tree/mvc2</a> (mvc2 branch of the MvcPaging repository).</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Cuyahoga 2.0 Alpha released</title>
		<link>http://blogs.taiga.nl/martijn/2009/12/12/cuyahoga-2-0-alpha-released/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/12/12/cuyahoga-2-0-alpha-released/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 15:32:51 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[Cuyahoga]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/12/12/cuyahoga-2-0-alpha-released/</guid>
		<description><![CDATA[Just a little post to let you know that I released the first Alpha of the next generation of the Cuyahoga CMS yesterday. For the people who don’t know Cuyahoga: it’s a .NET CMS that uses lots of Open Source components like NHibernate, Castle Windsor and Lucene.NET. Although not as polished as Umbraco or Dotnetnuke, [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little post to let you know that I released the first Alpha of the next generation of the <a href="http://cuyahoga-project.org">Cuyahoga</a> CMS yesterday. For the people who don’t know Cuyahoga: it’s a .NET CMS that uses lots of Open Source components like NHibernate, Castle Windsor and Lucene.NET. Although not as polished as <a href="http://umbraco.org" target="_blank">Umbraco</a> or <a href="http://www.dotnetnuke.com" target="_blank">Dotnetnuke</a>, I think it still shines when doing custom module and template development.</p>
<p>Development has been a long journey. Already back in 2006 we started development for the 2.0 version. In that time most of the work was done by Max Gaerber. He did a fantastic job in the design of the generic handling of content items.</p>
<p>Then somewhere in 2007 we started the new admin with Castle Monorail, did a spike with the first ASP.NET MVC, changed back to Monorail and finally changed to ASP.NET MVC again. The switch from ASP.NET WebForms to MVC for the site admin allowed us to do some pretty advanced AJAX stuff. The result is still a little rough around the edges, but it’s usable for experimental purposes. </p>
<p>Download it at <a title="http://sourceforge.net/projects/cuyahoga/files/" href="http://sourceforge.net/projects/cuyahoga/files/">http://sourceforge.net/projects/cuyahoga/files/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/12/12/cuyahoga-2-0-alpha-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Framework 4.0: a fresh start (with demo application)</title>
		<link>http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 21:31:42 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[O/R mapping]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/</guid>
		<description><![CDATA[Edited 2009-11-26: removed EF4 Feature CTP from demo package and added some code examples. So, Entity Framework 1.0 pretty much sucks (compared to alternatives), but I’m glad to see that things have improved a lot in version 4.0 (we’ll call that EF4 from now). To see how the improvements work out, I did a quick [...]]]></description>
			<content:encoded><![CDATA[<p>Edited 2009-11-26: removed EF4 Feature CTP from demo package and added some code examples.</p>
<p>So, <a href="http://blogs.taiga.nl/martijn/2009/09/24/one-year-after-the-entity-framework-vote-of-no-confidence/">Entity Framework 1.0 pretty much sucks</a> (compared to alternatives), but I’m glad to see that things have improved a lot in version 4.0 (we’ll call that EF4 from now). To see how the improvements work out, I did a quick <a href="http://blogs.taiga.nl/martijn/wp-content/uploads/EF4Demo.zip" target="_blank">spike</a> that also gave me the opportunity to test some new ASP.NET MVC 2 features that I might blog about later.</p>
<h3>What’s in it?</h3>
<ul>
<li>Entity Framework 4 with POCO entity objects and <a href="http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx" target="_blank">code-only configuration</a> (no edmx);</li>
<li>Data access abstracted via repository interfaces;</li>
<li>ASP.NET 2 MVC for the UI;</li>
<li>Validation with Data Annotations;</li>
<li>Castle Windsor IoC container to wire the various components together;</li>
</ul>
<h3>EF4 POCO</h3>
<p>In EF4, it’s now possible to use entity classes that don’t have to inherit from EntityObject. This allows for better testability and separation of concerns. This is how an entity looks in the demo:</p>
<pre class="brush: csharp;">public class Course
{
    public virtual int Id { get; set; }

    [Required(ErrorMessage="Course title is required")]
    public virtual string Title { get; set; }

    [Required(ErrorMessage = "Price is required")]
    [DataType(DataType.Currency)]
    [Range(10.00, double.MaxValue, ErrorMessage="The minimum price is {1}")]
    public virtual decimal Price { get; set; }

    public virtual ISet&lt;Schedule&gt; Schedules { get; set; }

    public Course()
    {
        this.Schedules = new HashSet&lt;Schedule&gt;();
    }
}</pre>
<p>Note that all properties are marked virtual. This allows EF4 to do some magic with run-time proxy generation to allow lazy loading and change notification.</p>
<p>Also note that we can now easily add validation attributes (in this case from Sytem.ComponentModel.DataAnnotations). We don’t have to use those <a href="http://ayende.com/Blog/archive/2009/05/04/the-buddy-classes-are-drowning-dry.aspx" target="_blank">dreadful ‘buddy classes’</a> anymore to hold the meta-data.</p>
<h3>Code-only configuration</h3>
<p>EF4 now allows model-first design from the VS 2010 designer, but it can still get awkward with a lot of entities. Fortunately, the <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=13fdfce4-7f92-438f-8058-b5b4041d0f01" target="_blank">EF4 Feature CTP</a> makes it possible <a href="http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx" target="_blank">to do everything in code</a>.</p>
<p>So you now just create your POCO entity and add a mapping class that replaces the edmx designer:</p>
<pre class="brush: csharp;">public class CourseMapping : EntityConfiguration&lt;Course&gt;
{
    public CourseMapping()
    {
        HasKey(c =&gt; c.Id);
        Property(c =&gt; c.Id).IsIdentity();
        MapSingleType(c =&gt; new
        {
            courseid = c.Id,
            title = c.Title,
            price = c.Price
        }).ToTable("course");
        Property(c =&gt; c.Price).HasStoreType("money").HasPrecision(19, 4);
    }
}</pre>
<p>Looks remarkably similar to <a href="http://wiki.fluentnhibernate.org/Main_Page" target="_blank">Fluent NHibernate</a>, doesn’t it? <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I’m not sure if this is the most optimal way to define the mapping, but it works. In the demo, there is a class CoursesContextBuilder that wraps the ContextBuilder from the EF4 Feature CTP where the mappings are added. It also serves as a factory for new ObjectContext instances () :</p>
<pre class="brush: csharp;">public class CoursesContextBuilder
{
    private ContextBuilder&lt;ObjectContext&gt; _builder;
    private string _defaultConnectionString;

    public CoursesContextBuilder(string defaultConnectionString)
    {
        this._defaultConnectionString = defaultConnectionString;
        this._builder = new ContextBuilder&lt;ObjectContext&gt;();
        ConfigureMappings();
    }

    private void ConfigureMappings()
    {
        _builder.Configurations.Add(new TeacherMapping());
        _builder.Configurations.Add(new CourseMapping());
        _builder.Configurations.Add(new ScheduleMapping());
    }

    public ObjectContext GetContext()
    {
        return GetContext(_defaultConnectionString);
    }

    public ObjectContext GetContext(string connectionString)
    {
        var context = _builder.Create(GetConnection(connectionString));
        context.ContextOptions.LazyLoadingEnabled = true;
        return context;
    }

    private DbConnection GetConnection(string connectionString)
    {
        // Hardcoded to SqlConnection for this demo.
        return new SqlConnection(connectionString);
    }
}</pre>
<p>That’s all we need to get EF4 working. In theory, we can now do everything with the POCO classes and the ObjectContext that comes from the CoursesContextBuilder, but of course if we would use it this way, we are directly tied to EF again and there goes away our testability.</p>
<h3>Repository implementation</h3>
<p>To make sure our application code isn’t tied to EF directly, data access goes through Repository interfaces. In the demo app you can find a generic IRepository&lt;T&gt; interface that is implemented by an EfRepository&lt;T&gt; class. The EfRepository implementation uses the EF ObjectContext to perform queries and so on. Note that we added an extra IContextManager interface that the EfRepository depends on. The IContextManager is responsible for managing the lifetime of the ObjectContext that is obtained from the ContextBuilder. This way, the repository implementations don’t have to worry about creating and disposing ObjectContext instances. It’s just always always available.All specific Repository interfaces inherit from IRepository&lt;T&gt; and the specific implementations inherit from EfRepository&lt;T&gt;.</p>
<pre class="brush: csharp;">public interface ICourseRepository : IRepository&lt;Course&gt;
{
    void DeleteCourseWithSchedule(Course course);
    Ef4Poco.Domain.Course GetCourseWithSchedulesAndTeachers(int courseId);
    void RemoveScheduleFromCourse(Schedule schedule, Course course);
}</pre>
<pre class="brush: csharp;">/// &lt;summary&gt;
/// Course-specific repository.
/// &lt;/summary&gt;
public class CourseRepository : EfRepository&lt;Course&gt;, ICourseRepository
{
    public CourseRepository(IContextManager contextManager)
        : base(contextManager)
    { }

    public Course GetCourseWithSchedulesAndTeachers(int courseId)
    {
        // Wouldn't it be nice to have strong-typed includes?
        var query = from c in ObjectSet.Include("Schedules").Include("Schedules.Teacher")
                    where c.Id == courseId
                    select c;
        return query.Single();
    }

    public void RemoveScheduleFromCourse(Schedule schedule, Course course)
    {
        course.Schedules.Remove(schedule);
        CurrentObjectContext.DeleteObject(schedule);
        CurrentObjectContext.SaveChanges();
    }

    public void DeleteCourseWithSchedule(Course course)
    {
        // Howto configure cascade delete via code? This is a little cumbersome.
        var schedules = new List&lt;Schedule&gt;(course.Schedules);
        foreach (var schedule in schedules)
        {
            CurrentObjectContext.DeleteObject(schedule);
        }
        CurrentObjectContext.DeleteObject(course);
        CurrentObjectContext.SaveChanges();
    }
}</pre>
<h3>Consuming the data access interfaces</h3>
<p>Now we have our data access interfaces in place, it’s time for consuming. This is plain simple. Below is an example of how a controller in the ASP.NET MVC app in the demo uses the interfaces:</p>
<pre class="brush: csharp;">public class TeachersController : Controller
{
    private ITeacherRepository _teacherRepository;

    public TeachersController(ITeacherRepository teacherRepository)
    {
        _teacherRepository = teacherRepository;
    }

    public ActionResult Index()
    {
        var teachers = _teacherRepository.Find().OrderBy(t =&gt; t.Name);
        return View(teachers);
    }

    [...snip other methods]
}</pre>
<h3>The demo app</h3>
<p>You can<a href="http://blogs.taiga.nl/martijn/wp-content/uploads/EF4Demo.zip" target="_blank"> download the demo</a> to see what’s possible. It’s by no means a best practices example. Just a spike to test out various new technologies.</p>
<p>To run the demo, you’ll need Visual Studio 2010 Beta 2, <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=13fdfce4-7f92-438f-8058-b5b4041d0f01" target="_blank">the latest EF4 Feature CTP</a> and SQL Server (Express).</p>
<p>Both, the web and the test project have a connection string in the config file that defaults to the .\SQLEXPRESS instance. Change that if you want to use a different instance. The database name doesn’t matter because a new database will be created the first time you run the application. Note that the reference to the EF4 feature CTP (Microsoft.Data.Entity.CTP.dll) points to C:\Program Files (x86)\Microsoft ADO.NET Entity Framework Feature CTP2\Binaries. On 32 bit machines, you’ll probably have to change that to C:\Program Files\…</p>
<h3>Some observations</h3>
<ul>
<li>Entity Framework 4.0 is much, much better than version 1.0, especially for a model-first approach;</li>
<li>It’s not on par yet with <a href="http://nhforge.org" target="_blank">NHibernate</a> feature-wise (for example, I really miss cascade settings). Given the choice, I’d still opt for NHibernate, but it’s not a bad product anymore and I&#8217;d prefer it over LINQ to SQL at this time.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Considering ASP.NET MVC UI controls? Learn HTML and Javascript!</title>
		<link>http://blogs.taiga.nl/martijn/2009/08/13/considering-asp-net-mvc-ui-controls-learn-html-and-javascript/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/08/13/considering-asp-net-mvc-ui-controls-learn-html-and-javascript/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 09:31:16 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[WebForms]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/08/13/considering-asp-net-mvc-ui-controls-learn-html-and-javascript/</guid>
		<description><![CDATA[Warning: highly subjective content ahead. In the recent weeks we’ve seen several control vendors come up with toolkits that target ASP.NET MVC. Personally, I don’t see anything that might make me starting to consider picking one of these toolkits to speed up development. Why on earth would I prefer a wrapper around jQuery UI or [...]]]></description>
			<content:encoded><![CDATA[<p>Warning: highly subjective content ahead.</p>
<p>In the recent weeks we’ve seen <a href="http://www.telerik.com/products/aspnet-mvc.aspx" target="_blank">several</a> <a href="http://mvc.devexpress.com/" target="_blank">control</a> <a href="http://www.syncfusion.com/products/aspnet-mvc" target="_blank">vendors</a> come up with toolkits that target ASP.NET MVC. Personally, I don’t see anything that might make me starting to consider picking one of these toolkits to speed up development. Why on earth would I prefer a wrapper around jQuery UI or shoehorning existing WebForms controls in MVC views?</p>
<p>The beauty of ASP.NET MVC is that it embraces the web as it is and this automatically involves HTML, CSS and Javascript. Don’t be afraid for that. The combination can be so powerful! Why aren’t there any large component vendors for PHP, Rails, Django etc? Isn’t it probably possible that these components are not required to do proper web development?</p>
<p>The control vendors seem to be targeting people who come from a Windows background that don’t want to learn HTML and Javascript, but from my experiences I can say that those people should really stick to WebForms.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/08/13/considering-asp-net-mvc-ui-controls-learn-html-and-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ASP.NET WebForms and MVC together in one project</title>
		<link>http://blogs.taiga.nl/martijn/2009/06/03/aspnet-webforms-and-mvc-together-in-one-project/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/06/03/aspnet-webforms-and-mvc-together-in-one-project/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 21:40:54 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Area]]></category>
		<category><![CDATA[Sample]]></category>
		<category><![CDATA[WebForms]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/06/03/aspnet-webforms-and-mvc-together-in-one-project/</guid>
		<description><![CDATA[This post briefly describes a solution to mix ASP.NET WebForms and MVC in one project. You can download a sample project that might be more useful than my ramblings. Download the sample here, unzip, open with VS 2008 SP1 and hit F5. There are lots of ‘legacy’ ASP.NET WebForms applications out there in the wild. [...]]]></description>
			<content:encoded><![CDATA[<p><em>This post briefly describes a solution to mix ASP.NET WebForms and MVC in one project. You can download a sample project that might be more useful than my ramblings. <a href="http://blogs.taiga.nl/martijn/wp-content/uploads/WebFormsMVCDemo.zip" target="_blank">Download the sample here</a>, unzip, open with VS 2008 SP1 and hit F5.</em></p>
<p>There are lots of ‘legacy’ ASP.NET WebForms applications out there in the wild. What if you want to create new functionality or rebuild an existing part with ASP.NET MVC, but you can’t (or won’t) create a separate new project?</p>
<p>The simple solution is to add the default MVC folders (Content, Controlllers, Scripts, Views etc.) to the root of the web project, add references to the MVC binaries, modify web.config and add the MVC GUID to the ProjectTypeGuids in the project file. A major drawback however is that it pollutes the root of your carefully structured application. This post will show you how you can logically separate the new MVC pieces from the existing WebForms app in a single project.</p>
<h3>Isolate the MVC bits</h3>
<p><img title="webforms-mvc-solution" style="border-right: 0px; border-top: 0px; display: inline; margin-left: 0px; border-left: 0px; margin-right: 0px; border-bottom: 0px" height="449" alt="webforms-mvc-solution" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2009/06/webformsmvcsolution3.png" width="297" align="right" border="0" />&#160; A simple requirement: I want that all my MVC folders reside in the folder /MyMvcApp <em>and </em>I also want that all urls of the MVC app start with /mymvcapp. No interference with my old WebForms app please.</p>
<h3></h3>
<h3>Area’s</h3>
<p>About a year ago, <a href="http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx">Phil Haacked showed a concept called area’s</a> to partition an ASP.NET MVC application. After that, <a href="http://blog.codeville.net/2008/11/05/app-areas-in-aspnet-mvc-take-2/">Steve Sanderson came up with an improved version</a> of the concept.</p>
<p>Although designed to partition an MVC application, area’s are also useful when we want to isolate our MVC application from our existing WebForms app. <a href="http://blog.codeville.net/2008/11/05/app-areas-in-aspnet-mvc-take-2/" target="_blank">The solution from Steve Sanderson</a> almost completely fits our needs, follow the link for more technical details. The only thing I removed was the usage of an Areas subfolder in the project where all the individual MVC sub-applications. Simply didn’t need the extra subfolder and url of the MVC app is closer to the physical structure.</p>
<p>So, I implemented area’s with a specific AreaViewEngine that can lookup views based on the area name and added the extension to the RouteCollection class to add area information when mapping routes. This is how Global.asax.cs looks:</p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> Application_Start(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">{</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    ViewEngines.Engines.Clear();</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">    ViewEngines.Engines.Add(<span style="color: #0000ff">new</span> AreaViewEngine());</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">&#160;</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">    <span style="color: #008000">// Routes</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    RegisterRoutes(RouteTable.Routes);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">}</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">&#160;</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> RegisterRoutes(RouteCollection routes)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">{</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">    routes.IgnoreRoute(<span style="color: #006080">&quot;{resource}.axd/{*pathInfo}&quot;</span>);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    routes.IgnoreRoute(<span style="color: #006080">&quot;{*favicon}&quot;</span>, <span style="color: #0000ff">new</span> { favicon = <span style="color: #006080">@&quot;(.*/)?favicon.ico(/.*)?&quot;</span> });</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">&#160;</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    routes.CreateArea(<span style="color: #006080">&quot;mymvcapp&quot;</span>, <span style="color: #006080">&quot;WebFormsMVCDemo.MyMvcApp.Controllers&quot;</span>,</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">        routes.MapRoute(<span style="color: #006080">&quot;mymvcapp-defaultroute&quot;</span>, <span style="color: #006080">&quot;mymvcapp/{controller}/{action}/{id}&quot;</span>, <span style="color: #0000ff">new</span> { action = <span style="color: #006080">&quot;Index&quot;</span>, controller = <span style="color: #006080">&quot;Home&quot;</span>, id = <span style="color: #006080">&quot;&quot;</span> })</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    );</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">}</pre>
<p><!--CRLF--></div>
</div>
<p>With the ViewEngine and routes in place, we’re able to run the MVC app from the url /mymvcapp. To make sure the WebForms url’s still work, we just have to add some ignore statements in Global.asax.cs (in our case, exclude .aspx and .ashx from routing):</p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> RegisterRoutes(RouteCollection routes)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">{</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    routes.IgnoreRoute(<span style="color: #006080">&quot;{resource}.axd/{*pathInfo}&quot;</span>);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">    routes.IgnoreRoute(<span style="color: #006080">&quot;{*allaspx}&quot;</span>, <span style="color: #0000ff">new</span> { allaspx = <span style="color: #006080">@&quot;.*\.aspx(/.*)?&quot;</span> });</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    routes.IgnoreRoute(<span style="color: #006080">&quot;{*allashx}&quot;</span>, <span style="color: #0000ff">new</span> { allashx = <span style="color: #006080">@&quot;.*\.ashx(/.*)?&quot;</span> });</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">    routes.IgnoreRoute(<span style="color: #006080">&quot;{*favicon}&quot;</span>, <span style="color: #0000ff">new</span> { favicon = <span style="color: #006080">@&quot;(.*/)?favicon.ico(/.*)?&quot;</span> });</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">&#160;</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">    routes.CreateArea(<span style="color: #006080">&quot;mymvcapp&quot;</span>, <span style="color: #006080">&quot;WebFormsMVCDemo.MyMvcApp.Controllers&quot;</span>,</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">        routes.MapRoute(<span style="color: #006080">&quot;mymvcapp-defaultroute&quot;</span>, <span style="color: #006080">&quot;mymvcapp/{controller}/{action}/{id}&quot;</span>, <span style="color: #0000ff">new</span> { action = <span style="color: #006080">&quot;Index&quot;</span>, controller = <span style="color: #006080">&quot;Home&quot;</span>, id = <span style="color: #006080">&quot;&quot;</span> })</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">    );</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">}</pre>
<p><!--CRLF--></div>
</div>
<p>One caveat: when performing the request for /mymvcapp without controller name (and action), the Default.aspx that comes with the MVC projects was loaded, but area’s seem so cause a problem with the default one. Instead of rewriting the url from ‘default.aspx’ to ‘/’, I had to rewrite to url to ‘Home/Index’:</p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">partial</span> <span style="color: #0000ff">class</span> _Default : Page</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">{</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Page_Load(<span style="color: #0000ff">object</span> sender, System.EventArgs e)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">    {</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">        <span style="color: #0000ff">string</span> pathToRewriteTo = Request.Path.ToLowerInvariant().Replace(<span style="color: #006080">&quot;default.aspx&quot;</span>, <span style="color: #006080">&quot;Home/Index&quot;</span>);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">        HttpContext.Current.RewritePath(pathToRewriteTo, <span style="color: #0000ff">false</span>);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">        IHttpHandler httpHandler = <span style="color: #0000ff">new</span> MvcHttpHandler();</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">        httpHandler.ProcessRequest(HttpContext.Current);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">    }</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">}</pre>
<p><!--CRLF--></div>
</div>
<p>I’m under the impression that I’m missing something very simple, but couldn’t get my fingers behind it, so if you know it, please comment.</p>
<p>&#160;</p>
<p>That’s it. I created a sample project with both WebForms and an MVC app in a subfolder. <a href="http://blogs.taiga.nl/martijn/wp-content/uploads/WebFormsMVCDemo.zip" target="_blank">You can download it here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/06/03/aspnet-webforms-and-mvc-together-in-one-project/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC bridging the gap with PHP development?</title>
		<link>http://blogs.taiga.nl/martijn/2009/05/07/aspnet-mvc-bridging-the-gap-with-php-development/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/05/07/aspnet-mvc-bridging-the-gap-with-php-development/#comments</comments>
		<pubDate>Thu, 07 May 2009 15:01:49 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/05/07/aspnet-mvc-bridging-the-gap-with-php-development/</guid>
		<description><![CDATA[For a long time, there has been a distinct separation between ASP.NET and PHP developers. The platforms have been so fundamentally different and also have the surrounding cultures. Generally speaking, ASP.NET developers consider the PHP guys script kiddies with no real understanding of ‘real’ software development and the PHP guys saw ASP.NET developers as some [...]]]></description>
			<content:encoded><![CDATA[<p><img title="Grand_Canyon6" style="display: inline" height="160" alt="Grand_Canyon6" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2009/05/grand-canyon61.jpg" width="240" align="right" /> For a long time, there has been a distinct separation between <a href="http://www.asp.net">ASP.NET</a> and <a href="http://www.php.net">PHP</a> developers. The platforms have been so fundamentally different and also have the surrounding cultures. Generally speaking, ASP.NET developers consider the PHP guys script kiddies with no real understanding of ‘real’ software development and the PHP guys saw ASP.NET developers as some M$ infected bunch of people that have no clue of web standards, clean HTML or how to build a proper web app at all.</p>
<p>But times have changed. Both platforms are moving. PHP now has a whole bunch of application frameworks (<a href="http://framework.zend.com/">Zend</a>, <a href="http://cakephp.org/">CakePHP</a> etc.) that encourage good application design and also since PHP 5, the programming language has improved a lot. On the other hand, with the release of ASP.NET MVC, it has become much more easy to render clean HTML and we can finally leverage all the cool client-side toolkits that are out there without having to work around the quirks of <a href="http://stackoverflow.com/questions/46031/why-does-the-aspnet-web-forms-model-suck">Web Forms</a>.&#160; </p>
<p>So, with this movement, we see that both platforms grow towards each other. More and more developers come to have a look over the fence to see what’s happening at the neighbours place.<img title="bridge-gap" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="159" alt="bridge-gap" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2009/05/bridgegap1.jpg" width="240" border="0" /></p>
<p>Two concrete examples:</p>
<ul>
<li>I’m consulting a little at a PHP shop that is moving towards .NET. They found Visual Studio and C# very cool, but the Web Forms issues regarding clean HTML etc. made it an absolute no-go. ASP.NET MVC is what made them switch.</li>
<li>Just watched the <a href="http://videos.visitmix.com/MIX09/T62F">ASP.NET MVC Mix 09 presentation</a> of <a href="http://blog.wekeroad.com/">Rob Conery</a> (Microsoft) and he showed lots of things that were clearly inspired by how PHP apps like <a href="http://wordpress.org">WordPress</a> work.</li>
</ul>
<ul>I like this movement! As a .NET developer, I find it very refreshing and inspiring to mix and mingle with ‘the other side’. There is a lot we can learn from each other to make better web applications.</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/05/07/aspnet-mvc-bridging-the-gap-with-php-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET development is like my pedalboard</title>
		<link>http://blogs.taiga.nl/martijn/2009/03/19/aspnet-development-is-like-my-pedalboard/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/03/19/aspnet-development-is-like-my-pedalboard/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 21:46:18 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Guitar]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/03/19/aspnet-development-is-like-my-pedalboard/</guid>
		<description><![CDATA[Warning: this post doesn’t only contain the usual software dev stuff, but also some serious guitar-geekiness. This morning, I was shocked when I found out how much the development of my pedalboard went through exactly the same stages as the way I’m building ASP.NET web applications. First let’s see where I’m coming from: In the [...]]]></description>
			<content:encoded><![CDATA[<p><em>Warning: this post doesn’t only contain the usual software dev stuff, but also some serious guitar-geekiness.</em></p>
<p>This morning, I was shocked when I found out how much the development of my <a href="http://en.wikipedia.org/wiki/Guitar_pedalboard">pedalboard</a> went through exactly the same stages as the way I’m building ASP.NET web applications. First let’s see where I’m coming from:</p>
<p><img title="pedalboard-before" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="225" alt="pedalboard-before" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2009/03/pedalboardbefore.jpg" width="300" border="0" /> </p>
<p>In the picture above you can see a large yellow device. This is the <a href="http://bx.line6.com/dm4/">Line 6 Distortion Modeler</a>. It claims that it can produce all the classic distorted guitar tones that you’ll ever want and to a certain extend this is true. The sound is alright and the possibilities are huge. But also: the output (sound wise) that this device produces is always less than the original pedals that it’s trying to emulate. Also, the switches are a little bit unreliable and cause a little gap when changing sounds. I tried to fix this, but the device is very inaccessible and doesn’t lend itself very well for modifications or extensions.</p>
<h3>Less is better</h3>
<p>These days I’m back to where I came from: two simple pedals that don’t have a gazillion options but just do their work and are very efficient:</p>
<p><img title="pedalboard-after" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="270" alt="pedalboard-after" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2009/03/pedalboardafter.jpg" width="360" border="0" /> </p>
<p>On the left we have the <a href="http://www.procosound.com/?page=viewprod&amp;cat=150&amp;id=741">Proco RAT</a> and on the right it’s the <a href="http://www.digitech.com/products/Pedals/BadMonkey.php">Digitech Bad Monkey</a> (‘told you we’d have some guitar-geek talk in this post, remember?). These guys are simple, reliable and their output is just the way I want my distortion to sound without losing dynamics and tone. Full control!</p>
<p><em>So, what does this have to do with ASP.NET web development?</em></p>
<p>Nothing of course <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  It just struck me that at about the same time I switched from ASP.NET Webforms to MVC, I also changed my pedalboard to accomplish the same result: making the end result better with a more simplistic approach. The yellow monster in the first picture is like Webforms with ASP.NET AJAX where I have a love-hate relationship with. The two pedals in de second picture feel like the MVC and jQuery combination (loosely coupled, only connected with a little patch cable), that brought a lot of fun lately and work very well for me.</p>
<p><em>Yeah, great analogy, NOT! I didn’t subscribe to read this blah about some guitar thingy.</em></p>
<p>Well it just something that went through my mind this morning and writing about it also gives me a chance to post some crappy gear pictures, like it or not. Here’s another one for free:</p>
<p><img title="family" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="300" alt="family" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2009/03/family.jpg" width="225" border="0" /> </p>
<p> <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>P.S. the empty spot above the pedals is normally reserved for my <a href="http://www.ehx.com/products/deluxe-memory-man">Electro Harmonix Memory Man Deluxe</a> but this drama queen is broken at the moment and deserves a single post of its own.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/03/19/aspnet-development-is-like-my-pedalboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How can we make the SharePoint world a better world?</title>
		<link>http://blogs.taiga.nl/martijn/2009/02/20/how-can-we-make-the-sharepoint-world-a-better-world/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/02/20/how-can-we-make-the-sharepoint-world-a-better-world/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 16:37:41 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/?p=63</guid>
		<description><![CDATA[Lots of companies are positioning SharePoint as their preferred platform for everything that has to do with the web, both intranet and public facing websites. Now out-of-the-box, SharePoint delivers excellent value, but when building custom functionality or public facing sites, there are some serious issues. My biggest gripes are: The whole development experience is awful. [...]]]></description>
			<content:encoded><![CDATA[<p>Lots of companies are positioning SharePoint as their preferred platform for everything that has to do with the web, both intranet and public facing websites. Now out-of-the-box, SharePoint delivers excellent value, but when building custom functionality or public facing sites, there are some serious issues.</p>
<p>My biggest gripes are:</p>
<ul>
<li>The whole development experience is awful. Yes, you can create custom webparts, but I&#8217;ve yet to come across the one that isn&#8217;t a <a href="http://en.wikipedia.org/wiki/Big_ball_of_mud" target="_blank">big ball of mud</a>. Also, the entire cycle of compiling, deploying and testing takes way too long to be productive at all. One minute is pretty common. Gosh, I wonder why all these projects are late every time <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ;</li>
<li>The HTML output is a mess. Not so much a problem for intranets, but for public sites it is. With a zillion tweaks, it is possible to fix it, but then again, no wonder these projects are late every time;</li>
</ul>
<p>I&#8217;ve been thinking how to improve this situation. Sure, I could say: &#8220;just don&#8217;t use SharePoint for your public web sites&#8221;, but companies are going to push everything to Sharepoint anyway. The whitepapers and consultants will tell them that everything is possible and it&#8217;s from Microsoft, so it&#8217;s a safe bet. We (as in Microsoft developers) simply have to deal with it the next years.</p>
<h3>A Cunning Plan</h3>
<p>First: let&#8217;s focus on publishing sites. I want to have:</p>
<ul>
<li>Clean standards-based HTML;</li>
<li>Clean url&#8217;s;</li>
<li>The ability to add custom applications as a feature without being restricted to webparts, or even better: develop applications standalone and deploy to Sharepoint when they&#8217;re ready;</li>
<li>Leverage the SharePoint infrastructure (sites, lists, security, etc);</li>
</ul>
<p>Looks impossible but is it really?</p>
<p>Couldn&#8217;t we not drop in System.Web.Routing, create a special SharePointRouteHandler, that sets up required sharepoint infrastructure and delegates the request to a Controller to have ASP.NET MVC within the SharePoint context? I think it&#8217;s hard and complex, but not impossible. We could leverage all strong points of ASP.NET MVC like separation of concerns, testability, clean HTML together with the huge foundation that SharePoint offers.</p>
<h3>Plan B</h3>
<p>Microsoft is already working on this situation and the next version of SharePoint will address the situation properly.</p>
<p>Now, please tell me that I&#8217;m <strong>a</strong>: ambitious, <strong>b</strong>: naive or <strong>c</strong>: completely insane <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/02/20/how-can-we-make-the-sharepoint-world-a-better-world/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Paging demo upgraded to ASP.NET MVC RC</title>
		<link>http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 11:04:53 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/</guid>
		<description><![CDATA[The sample project that belongs to the Paging with ASP.NET MVC post is upgraded to ASP.NET MVC RC. Get it from here.]]></description>
			<content:encoded><![CDATA[<p>The sample project that belongs to <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/" target="_blank">the Paging with ASP.NET MVC post</a> is upgraded to ASP.NET MVC RC. <a href="http://blogs.taiga.nl/martijn/wp-content/uploads/2008/08/mvcpaging-rc1.zip">Get it from here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
