<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Human-Debugger.net - .Net 3.5|Asp.net MVC</title>
    <link>http://www.human-debugger.net/blog/</link>
    <description>Raba - Defend your code</description>
    <language>en-us</language>
    <copyright>Shani Raba</copyright>
    <lastBuildDate>Wed, 26 Jan 2011 23:08:47 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>human.debugger.net@gmail.com</managingEditor>
    <webMaster>human.debugger.net@gmail.com</webMaster>
    <item>
      <trackback:ping>http://www.human-debugger.net/blog/Trackback.aspx?guid=4354c4e5-7163-4d9c-ab44-253c28883916</trackback:ping>
      <pingback:server>http://www.human-debugger.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.human-debugger.net/blog/PermaLink,guid,4354c4e5-7163-4d9c-ab44-253c28883916.aspx</pingback:target>
      <dc:creator>Shani Raba</dc:creator>
      <wfw:comment>http://www.human-debugger.net/blog/CommentView,guid,4354c4e5-7163-4d9c-ab44-253c28883916.aspx</wfw:comment>
      <wfw:commentRss>http://www.human-debugger.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4354c4e5-7163-4d9c-ab44-253c28883916</wfw:commentRss>
      <title>AppHarbor &amp; Continuous Deployment</title>
      <guid isPermaLink="false">http://www.human-debugger.net/blog/PermaLink,guid,4354c4e5-7163-4d9c-ab44-253c28883916.aspx</guid>
      <link>http://www.human-debugger.net/blog/2011/01/26/AppHarborContinuousDeployment.aspx</link>
      <pubDate>Wed, 26 Jan 2011 23:08:47 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;This is my second post about AppHarbor, I suggest you to read &lt;a href="http://www.human-debugger.net/blog/2011/01/25/AppHarborThePlaceForHostingAspnetBonusGitForNewbies.aspx"&gt;my first impression&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;I am reading a lot about continuous deployment lately and AppHarbor provide great implementation for simple web applications deployment.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;strong&gt;Source Control&lt;/strong&gt; – Support Git to host your code&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Continuous integration&lt;/strong&gt; – Check build per commit and run NUnit as part of each build&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Deployment Script&lt;/strong&gt; – Each successful commit can be deploy in one click&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Rollback&lt;/strong&gt; – Even after passing build and tests it can be that you still have bugs, so you can simply check older version and deploy it till you commit a fix&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;img src="http://www.human-debugger.net/blog/sitedata/appharbor/workflow.png"&gt;&lt;br&gt;&lt;em&gt;Code and publish is so easy, this is by far this better than using FTP for such things and the option to run tests makes it even more fun.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;img src="http://www.human-debugger.net/blog/sitedata/appharbor/appharbor-myhistory.png"&gt;&lt;br&gt;&lt;em&gt;The option to rollback to previous commit\version is trivial but so important. Moreover, by clicking on “show”&lt;strong&gt; &lt;/strong&gt;you can check the build log and see the tests-run.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;/em&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;img src="http://www.human-debugger.net/blog/sitedata/appharbor/appharbor-tests.png"&gt;&lt;br&gt;&lt;em&gt;You can click the tests link to read more about each test&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Tip - UrlParameter does not exist:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;When first trying to deploy my code it failed during compilation. I got this output:&lt;br&gt;&lt;br&gt;&amp;nbsp; Global.asax.cs(18,67): error CS0103: The name 'UrlParameter' does not exist in the current context&lt;/p&gt; &lt;p&gt;I am not sure why, it could be that I am using early beta (didn’t update for a long time), anyhow I fixed this by changing the &lt;em&gt;global.asax.cs&lt;/em&gt; from using &lt;em&gt;UrlParamters.Optional&lt;/em&gt; to &lt;em&gt;""&lt;/em&gt;. You can read more here: &lt;a href="http://haacked.com/archive/2010/02/12/asp-net-mvc-2-optional-url-parameters.aspx"&gt;http://haacked.com/archive/2010/02/12/asp-net-mvc-2-optional-url-parameters.aspx&lt;/a&gt;&lt;/p&gt;&lt;img width="0" height="0" src="http://www.human-debugger.net/blog/aggbug.ashx?id=4354c4e5-7163-4d9c-ab44-253c28883916"/&gt;&lt;/div&gt;</description>
      <comments>http://www.human-debugger.net/blog/CommentView,guid,4354c4e5-7163-4d9c-ab44-253c28883916.aspx</comments>
      <category>.Net 3.5</category>
      <category>.Net 3.5/Asp.net MVC</category>
      <category>continuous deployment</category>
    </item>
    <item>
      <trackback:ping>http://www.human-debugger.net/blog/Trackback.aspx?guid=02cf7aa7-9a6a-47c4-b4f8-ca9d27da42b2</trackback:ping>
      <pingback:server>http://www.human-debugger.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.human-debugger.net/blog/PermaLink,guid,02cf7aa7-9a6a-47c4-b4f8-ca9d27da42b2.aspx</pingback:target>
      <dc:creator>Shani Raba</dc:creator>
      <wfw:comment>http://www.human-debugger.net/blog/CommentView,guid,02cf7aa7-9a6a-47c4-b4f8-ca9d27da42b2.aspx</wfw:comment>
      <wfw:commentRss>http://www.human-debugger.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=02cf7aa7-9a6a-47c4-b4f8-ca9d27da42b2</wfw:commentRss>
      <title>AppHarbor - The place for hosting asp.net (bonus: Git for newbies)</title>
      <guid isPermaLink="false">http://www.human-debugger.net/blog/PermaLink,guid,02cf7aa7-9a6a-47c4-b4f8-ca9d27da42b2.aspx</guid>
      <link>http://www.human-debugger.net/blog/2011/01/25/AppHarborThePlaceForHostingAspnetBonusGitForNewbies.aspx</link>
      <pubDate>Tue, 25 Jan 2011 13:49:00 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;Everyone knows Google app engine But what about .net apps? Meet &lt;a href="http://appharbor.com/"&gt;AppHarbor&lt;/a&gt; (Thanks &lt;a href="http://cloneable.lifshitz.net/"&gt;Gadi&lt;/a&gt;)&lt;/p&gt; &lt;p&gt;So I wanted to give it a chance and after playing for less than an hour:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Enable you to build \ host \ deploy web apps  &lt;li&gt;Provide both Version control and hosting service  &lt;li&gt;Absolutely free (for now)  &lt;li&gt;Damn simple&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Short tutorial on how to do it:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="https://appharbor.com/account/new"&gt;Create your appharbor account&lt;/a&gt; + create new application  &lt;li&gt;Hopefully you have Git installed (&lt;a href="http://code.google.com/p/msysgit/downloads/list"&gt;msysgit downloads&lt;/a&gt;)  &lt;li&gt;Init empty Git repository&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#a5a5a5"&gt;&lt;em&gt;git init test1&lt;/em&gt;&lt;/font&gt;  &lt;li&gt;Copy your files to this directory (download from here: &lt;a title="https://github.com/appharbor/appharbor-splash" href="https://github.com/appharbor/appharbor-splash"&gt;https://github.com/appharbor/appharbor-splash&lt;/a&gt;&amp;nbsp;&lt;a href="https://github.com/appharbor/appharbor-splash"&gt;)&lt;/a&gt; &lt;li&gt;Add files and subdirectories&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#a5a5a5"&gt;&lt;em&gt;git add .&lt;/em&gt;&lt;/font&gt;  &lt;li&gt;Create your remote repository&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;em&gt;&lt;font color="#a5a5a5"&gt;git remote add appharbor &lt;/font&gt;&lt;/em&gt;&lt;em&gt;&lt;font color="#a5a5a5"&gt;https://username@appharbor.com/test-178.git&lt;/font&gt;&lt;/em&gt;&lt;em&gt;&lt;font color="#a5a5a5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/em&gt;  &lt;li&gt;Commit your code&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;em&gt;&lt;font color="#a5a5a5"&gt;git commit -m 'firstcommit'&lt;/font&gt;&lt;/em&gt;  &lt;li&gt;Almost forgot, we are working on Git - so don't forget to push... &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;em&gt;&lt;font color="#a5a5a5"&gt;git push appharbor master&lt;/font&gt;&lt;/em&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Till here everything should work but I had a small issue, got this error: &lt;em&gt;&lt;font color="#a5a5a5"&gt;error setting certificate verify locations:&lt;/font&gt;&lt;/em&gt;&lt;br&gt;I've found out that it is all about versions (git --version) - So check yours and upgrade if needed&lt;/p&gt; &lt;p&gt;Here you can find great cheat sheet for Git commands: &lt;a href="http://ionrails.com/2009/08/07/git-commands-adding-and-committing-cheatsheet/"&gt;http://ionrails.com/2009/08/07/git-commands-adding-and-committing-cheatsheet/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Btw, AppHarbor support Databases and Running unit-testing after successful builds – I will post about those features later on.&lt;/p&gt;&lt;img width="0" height="0" src="http://www.human-debugger.net/blog/aggbug.ashx?id=02cf7aa7-9a6a-47c4-b4f8-ca9d27da42b2"/&gt;&lt;/div&gt;</description>
      <comments>http://www.human-debugger.net/blog/CommentView,guid,02cf7aa7-9a6a-47c4-b4f8-ca9d27da42b2.aspx</comments>
      <category>.Net 3.5</category>
      <category>.Net 3.5/Asp.net MVC</category>
      <category>Software Development/Agile</category>
    </item>
    <item>
      <trackback:ping>http://www.human-debugger.net/blog/Trackback.aspx?guid=891915ec-c4c7-4422-a9a0-28fca376a96e</trackback:ping>
      <pingback:server>http://www.human-debugger.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.human-debugger.net/blog/PermaLink,guid,891915ec-c4c7-4422-a9a0-28fca376a96e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.human-debugger.net/blog/CommentView,guid,891915ec-c4c7-4422-a9a0-28fca376a96e.aspx</wfw:comment>
      <wfw:commentRss>http://www.human-debugger.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=891915ec-c4c7-4422-a9a0-28fca376a96e</wfw:commentRss>
      <title>TechEd Eilat 2008 - Day 2</title>
      <guid isPermaLink="false">http://www.human-debugger.net/blog/PermaLink,guid,891915ec-c4c7-4422-a9a0-28fca376a96e.aspx</guid>
      <link>http://www.human-debugger.net/blog/2008/04/21/TechEdEilat2008Day2.aspx</link>
      <pubDate>Mon, 21 Apr 2008 01:56:16 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;This is the main day of TechEd were we had lectures from 8:00 till 19:00 Here are my list of lectures for that day:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Optimizing and Extending ASP.NET Ajax - for going beyond the update panel&amp;#160; - (by Assaf Shely)        &lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;This was a lecture of 400, at least that is what they wrote. in reality that was an introduction for Ajax, he explain about the update panel and about JSON. The only thing I want to add from this lecture is all he says about ASP.NET Ajax 3.6 - which can support browser history capabilities.     &lt;br /&gt;&lt;em&gt;My grade to Assaf's lecture: 6/10 (a big disappointment)&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;DDC &amp;amp; ASP.NET MVC (by &lt;a href="http://weblogs.asp.net/noamk/"&gt;Noam King&lt;/a&gt;)         &lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;DDC - dynamic data controls (you can read &lt;a href="http://quickstarts.asp.net/Futures/dynamicdatacontrols/default.aspx"&gt;here&lt;/a&gt;), MVC - Model View Controller (you can read more in &lt;a href="http://www.human-debugger.net/MVCAspnetMVCFrameworkControllerFactory.aspx"&gt;my last post about ASP.NET MVC&lt;/a&gt;).     &lt;br /&gt;Noam showed a simple usage of the MVC API, and a simple creation of a web site from the DDC API, those both samples are the simple web casts you can find and learn in 15 minutes. a big waste of time (again)     &lt;br /&gt;&lt;em&gt;My grade to Noam's lecture: 8/10 (Noam is a great lecturer, the problem was the level of the lecture - All they should do is to write: &lt;strong&gt;&lt;u&gt;Intro&lt;/u&gt;&lt;/strong&gt; at the beginning of the lecture description)&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Service Host Customization (by &lt;a href="http://weblogs.asp.net/vardi/"&gt;Eyal Vardi&lt;/a&gt;)         &lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;Finally a great lecture for the second day. It was a great one. you can download the lecture &lt;strong&gt;&lt;u&gt;&lt;em&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/vardi/archive/2008/04/07/servicehost-customization-teched-eliat-2008.aspx"&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/u&gt;&lt;/strong&gt;.    &lt;br /&gt;Eyal showed a great sample for Config manager - which helps you manage your configurations details (addresses for example) - and in such way you can manage it inside your DB or something else - better than a configuration file (it gave me some great ideas for my next posts).     &lt;br /&gt;He also used the ServiceHost VIsualizer - I even started to use it at my place.    &lt;br /&gt;Next we dive into the Service Model Layer and its behaviors. &lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.human-debugger.net/sitedata/wcf/service_model_layer.jpg" /&gt; &lt;/p&gt;  &lt;p&gt;I'll probably write about each of them in the near future.   &lt;br /&gt;For now, there were 4 demos:&lt;/p&gt;  &lt;p&gt;Demo 1: CD - Channel dispatcher - writing you own Error Handler, we also talk about the throttling.   &lt;br /&gt;Demo 2: Saving persistence of the Service inside a given Service Host.    &lt;br /&gt;Demo 3: DR - Object Pooling using the Dispatcher Runtime, it is a great sample.    &lt;br /&gt;Demo 4: Serialization Issues - Eyal wrote a sample-infrastructure for handling Serialization and DeSerialization without using the known-types.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Go Gold with Silverlight (by Laurence Moroney)&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This was an Introduction to Silverlight (of course), the only thing I liked about the lecture is the way he explained the differences between Silverlight 1.0 to Silverlight 2, while Silverlight 1.0 - is web friendly UI the Silverlight 2 - is .net based programming model with improve productivity. Laurence showed some cool samples (most of them you can find &lt;strong&gt;&lt;a href="http://silverlight.net/community/gallerydetail.aspx?cat=5"&gt;&lt;em&gt;here&lt;/em&gt;&lt;/a&gt;&lt;em&gt;,&lt;/em&gt; &lt;em&gt;&lt;a href="http://www.wynapse.com/Silverlight.aspx"&gt;here&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/brada/archive/tags/Silverlight/default.aspx"&gt;here&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/webnext/"&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;), the one I liked the most is a Server servlet (written using J2EE) but the client that consume it is a .net web client (Silverlight) - at my place, one of our teamd, has some Java assets and they want to use it, so they start develop their own UI like in Java for movies\Audio\Web-Parts\Ajax capabilities - this sample could help them a lot.&lt;/p&gt;  &lt;p&gt;My grade to the Laurence lecture is 7/10 - Laurence was great the problem was the lecture agenda - I really had enough from the Silverlight previews (so either call it preview\intro or show some code in it)   &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Restfulness (by Ron Jacobs)        &lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;First you should read this &lt;a href="http://www.amazon.com/RESTful-Web-Services-Leonard-Richardson/dp/0596529260"&gt;book&lt;/a&gt; (as they said - this is all you need to know about REST)     &lt;br /&gt;After &lt;a href="http://www.human-debugger.net/TechEdEilat2008Day1.aspx"&gt;David Chappell's lecture&lt;/a&gt; about REST for the first day people told me not to take another REST-lecture, but I did - and - IT WAS GREAT!.     &lt;br /&gt;you can read more on Avi's post. Ron gave more details about the implementation of REST using the WCF. for example:     &lt;br /&gt;How do you notify the sender about error in REST, you can't send XML back to the client... The answer is simple: for example for deleting non-existing row you will get 404 (HTTP Error code) - I might admit I like this one, the problem is that you should write your own fault architecture to return those codes back, _still_ not implemented at the REST attributes of the WCF. (one more sample: an internal error in your code will probably should return 500 - un-handled exception)     &lt;br /&gt;Here is another thing that is still not so easy to do in your WCF implementation - how you can ask for a response? for example you would like to get the JSON return value and not the simple xml... in REST - all you need to do is to add the extension to your request, but you still need to implement it in the WebMethodAttribute by yourself.     &lt;br /&gt;And there were more samples, you can download them &lt;a href="http://blogs.msdn.com/rjacobs/archive/2008/04/07/my-first-wcf-rest-talk-at-tech-ed-israel.aspx"&gt;here&lt;/a&gt;... (&lt;a href="http://blogs.msdn.com/rjacobs/"&gt;Ron's website&lt;/a&gt;). {&lt;a href="http://blogs.microsoft.co.il/blogs/aviwortzel/archive/2008/04/08/tech-ed-eilat-my-favorite-lectures.aspx"&gt;you can also read&amp;#160; more in Wortzel's post&lt;/a&gt;}    &lt;br /&gt;My grade to Ron's lecture is: 9/10.&lt;/p&gt;&lt;img width="0" height="0" src="http://www.human-debugger.net/blog/aggbug.ashx?id=891915ec-c4c7-4422-a9a0-28fca376a96e"/&gt;&lt;/div&gt;</description>
      <comments>http://www.human-debugger.net/blog/CommentView,guid,891915ec-c4c7-4422-a9a0-28fca376a96e.aspx</comments>
      <category>.Net 3.5</category>
      <category>.Net 3.5/Asp.net MVC</category>
      <category>.Net 3.5/C#3.0</category>
      <category>.Net 3.5/LINQ</category>
    </item>
    <item>
      <trackback:ping>http://www.human-debugger.net/blog/Trackback.aspx?guid=8737faa4-c281-419a-82bd-019556e49449</trackback:ping>
      <pingback:server>http://www.human-debugger.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.human-debugger.net/blog/PermaLink,guid,8737faa4-c281-419a-82bd-019556e49449.aspx</pingback:target>
      <dc:creator>Shani Raba</dc:creator>
      <wfw:comment>http://www.human-debugger.net/blog/CommentView,guid,8737faa4-c281-419a-82bd-019556e49449.aspx</wfw:comment>
      <wfw:commentRss>http://www.human-debugger.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=8737faa4-c281-419a-82bd-019556e49449</wfw:commentRss>
      <title>MVC (asp.net MVC Framework) - Controller Factory</title>
      <guid isPermaLink="false">http://www.human-debugger.net/blog/PermaLink,guid,8737faa4-c281-419a-82bd-019556e49449.aspx</guid>
      <link>http://www.human-debugger.net/blog/2008/01/16/MVCAspnetMVCFrameworkControllerFactory.aspx</link>
      <pubDate>Wed, 16 Jan 2008 00:04:15 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;I am not going to explain here nor about MVC neither about the ASP.NET 3.6 (yes it is 3.6, they didn't tell you that?!) I just gonna write a little bit about a sample application I wrote to myself. &lt;br&gt;Those of you who want to learn more about MVC (the pattern itself) - you can read in &lt;a href="http://martinfowler.com/eaaDev/uiArchs.html"&gt;Martin Fowler's post&lt;/a&gt; or maybe here at &lt;a href="http://en.wikipedia.org/wiki/Model-view-controller"&gt;wiki&lt;/a&gt; anyway there is even a better place to learn this in the &lt;a href="http://en.wikipedia.org/wiki/Model-view-controller"&gt;Head First - Design Patterns book&lt;/a&gt;. &lt;br&gt;Also you might read about the new asp.net MVC Framework (CTP), you can choose whether to read &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx"&gt;this (long but very important article&lt;/a&gt;) or you can see the &lt;a href="http://www.hanselman.com/blog/ASPNET35ExtensionsPlusMVCHowToScreencast.aspx"&gt;intro webcast&lt;/a&gt; (damn you lazy programmers)&lt;/p&gt; &lt;p&gt;Microsoft are doing well to cause us work harder just to learn the technology, this asp.net MVC implementation is awesome but It is a huge change for all of you ASP.NET people, I hope I find the time to write more about it, but here is one sample I wrote for myself.&lt;/p&gt; &lt;p&gt;&lt;img src="http://weblogs.asp.net/blogs/leftslipper/WindowsLiveWriter/ASP.NETMVCDesignPhilosophy_F491/MVC_Snake_2.png" width="640" height="480"&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From Request to Response through the MVC Flow &lt;/p&gt; &lt;p&gt;On each request there is a place that the Controller has its constructor calls and this will initiate your logic, I found it very useful to manage this controller creation. In this example I create my own Factory and there I manage to create the controller using another constructor (not the default one), moreover I can also add my own logic such as Security Check (in our sample) or something else useful.&lt;/p&gt; &lt;p&gt;Here is my own Controller Factory logic:&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:a8ce9433-9cf0-4c30-ada4-6cd1dd668aab" class="wlWriterSmartContent"&gt;&lt;pre style="background-color: #ffff80"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080"&gt; 1&lt;/span&gt; &lt;span style="color: #000000"&gt;    &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;span style="color: #000000"&gt; ShaniControllerFactory : IControllerFactory
&lt;/span&gt;&lt;span style="color: #008080"&gt; 2&lt;/span&gt; &lt;span style="color: #000000"&gt;    {
&lt;/span&gt;&lt;span style="color: #008080"&gt; 3&lt;/span&gt; &lt;span style="color: #000000"&gt;        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;#region&lt;/span&gt;&lt;span style="color: #000000"&gt; IControllerFactory Members&lt;/span&gt;&lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt; 4&lt;/span&gt; &lt;span style="color: #000000"&gt;        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;&lt;span style="color: #000000"&gt; IsUserExists 
&lt;/span&gt;&lt;span style="color: #008080"&gt; 5&lt;/span&gt; &lt;span style="color: #000000"&gt;        { 
&lt;/span&gt;&lt;span style="color: #008080"&gt; 6&lt;/span&gt; &lt;span style="color: #000000"&gt;            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;get&lt;/span&gt;&lt;span style="color: #000000"&gt; 
&lt;/span&gt;&lt;span style="color: #008080"&gt; 7&lt;/span&gt; &lt;span style="color: #000000"&gt;            {   &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt;Put here your great Logic&lt;/span&gt;&lt;span style="color: #008000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt; 8&lt;/span&gt; &lt;span style="color: #008000"&gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;                &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;&lt;span style="color: #000000"&gt;; 
&lt;/span&gt;&lt;span style="color: #008080"&gt; 9&lt;/span&gt; &lt;span style="color: #000000"&gt;            } 
&lt;/span&gt;&lt;span style="color: #008080"&gt;10&lt;/span&gt; &lt;span style="color: #000000"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080"&gt;11&lt;/span&gt; &lt;span style="color: #000000"&gt;        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;&lt;span style="color: #000000"&gt; IsUserAuthorizedForEdit 
&lt;/span&gt;&lt;span style="color: #008080"&gt;12&lt;/span&gt; &lt;span style="color: #000000"&gt;        { 
&lt;/span&gt;&lt;span style="color: #008080"&gt;13&lt;/span&gt; &lt;span style="color: #000000"&gt;            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;get&lt;/span&gt;&lt;span style="color: #000000"&gt; 
&lt;/span&gt;&lt;span style="color: #008080"&gt;14&lt;/span&gt; &lt;span style="color: #000000"&gt;            {   &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt;Again Special Logic for Checking Authorization&lt;/span&gt;&lt;span style="color: #008000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt;15&lt;/span&gt; &lt;span style="color: #008000"&gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;                &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;&lt;span style="color: #000000"&gt;;
&lt;/span&gt;&lt;span style="color: #008080"&gt;16&lt;/span&gt; &lt;span style="color: #000000"&gt;            } 
&lt;/span&gt;&lt;span style="color: #008080"&gt;17&lt;/span&gt; &lt;span style="color: #000000"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080"&gt;18&lt;/span&gt; &lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt;19&lt;/span&gt; &lt;span style="color: #000000"&gt;        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; IController CreateController(RequestContext context, Type controllerType)
&lt;/span&gt;&lt;span style="color: #008080"&gt;20&lt;/span&gt; &lt;span style="color: #000000"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080"&gt;21&lt;/span&gt; &lt;span style="color: #000000"&gt;            IController controller &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;&lt;span style="color: #000000"&gt;;
&lt;/span&gt;&lt;span style="color: #008080"&gt;22&lt;/span&gt; &lt;span style="color: #000000"&gt;            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (&lt;/span&gt;&lt;span style="color: #000000"&gt;!&lt;/span&gt;&lt;span style="color: #000000"&gt;IsUserExists)
&lt;/span&gt;&lt;span style="color: #008080"&gt;23&lt;/span&gt; &lt;span style="color: #000000"&gt;            {
&lt;/span&gt;&lt;span style="color: #008080"&gt;24&lt;/span&gt; &lt;span style="color: #000000"&gt;                controller &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; NotAuthorizedController();
&lt;/span&gt;&lt;span style="color: #008080"&gt;25&lt;/span&gt; &lt;span style="color: #000000"&gt;                &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; controller;
&lt;/span&gt;&lt;span style="color: #008080"&gt;26&lt;/span&gt; &lt;span style="color: #000000"&gt;            }
&lt;/span&gt;&lt;span style="color: #008080"&gt;27&lt;/span&gt; &lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt;28&lt;/span&gt; &lt;span style="color: #000000"&gt;            &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt;Distinct between those two&lt;/span&gt;&lt;span style="color: #008000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt;29&lt;/span&gt; &lt;span style="color: #008000"&gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (&lt;/span&gt;&lt;span style="color: #000000"&gt;!&lt;/span&gt;&lt;span style="color: #000000"&gt;IsUserAuthorizedForEdit)
&lt;/span&gt;&lt;span style="color: #008080"&gt;30&lt;/span&gt; &lt;span style="color: #000000"&gt;            {
&lt;/span&gt;&lt;span style="color: #008080"&gt;31&lt;/span&gt; &lt;span style="color: #000000"&gt;                controller &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; Activator.CreateInstance(controllerType,(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&lt;span style="color: #000000"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;&lt;span style="color: #000000"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff"&gt;as&lt;/span&gt;&lt;span style="color: #000000"&gt; IController;
&lt;/span&gt;&lt;span style="color: #008080"&gt;32&lt;/span&gt; &lt;span style="color: #000000"&gt;            }
&lt;/span&gt;&lt;span style="color: #008080"&gt;33&lt;/span&gt; &lt;span style="color: #000000"&gt;            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt;34&lt;/span&gt; &lt;span style="color: #000000"&gt;            {
&lt;/span&gt;&lt;span style="color: #008080"&gt;35&lt;/span&gt; &lt;span style="color: #000000"&gt;                controller &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; Activator.CreateInstance(controllerType, (&lt;/span&gt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;&lt;span style="color: #000000"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff"&gt;as&lt;/span&gt;&lt;span style="color: #000000"&gt; IController;
&lt;/span&gt;&lt;span style="color: #008080"&gt;36&lt;/span&gt; &lt;span style="color: #000000"&gt;            }
&lt;/span&gt;&lt;span style="color: #008080"&gt;37&lt;/span&gt; &lt;span style="color: #000000"&gt;            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; controller;
&lt;/span&gt;&lt;span style="color: #008080"&gt;38&lt;/span&gt; &lt;span style="color: #000000"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080"&gt;39&lt;/span&gt; &lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt;40&lt;/span&gt; &lt;span style="color: #000000"&gt;        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt;41&lt;/span&gt; &lt;span style="color: #000000"&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can simply see the &lt;em&gt;CreateController&lt;/em&gt; method (&lt;em&gt;lines: 19-38&lt;/em&gt;) where I put my logic for the Controls initiation, and I simply prefer creating them using my constructor (the one with the bool parameter) and not using the default one. &lt;br&gt;But, How will we have this Controller Factory running instead of the generic factory? It is very simple:&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:c9990e3f-c4da-4e79-a39e-781e4d19b5ef" class="wlWriterSmartContent"&gt;&lt;pre style="background-color: #ffff80"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080"&gt; 1&lt;/span&gt; &lt;span style="color: #000000"&gt;        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;protected&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt;&lt;span style="color: #000000"&gt; Application_Start(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&lt;span style="color: #000000"&gt; sender, EventArgs e)
&lt;/span&gt;&lt;span style="color: #008080"&gt; 2&lt;/span&gt; &lt;span style="color: #000000"&gt;        {
&lt;/span&gt;&lt;span style="color: #008080"&gt; 3&lt;/span&gt; &lt;span style="color: #000000"&gt;            ControllerBuilder.Current.SetDefaultControllerFactory(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000"&gt;(ShaniControllerFactory));
&lt;/span&gt;&lt;span style="color: #008080"&gt; 4&lt;/span&gt; &lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt; 5&lt;/span&gt; &lt;span style="color: #000000"&gt;            RouteTable.Routes.Add(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; Route
&lt;/span&gt;&lt;span style="color: #008080"&gt; 6&lt;/span&gt; &lt;span style="color: #000000"&gt;            {
&lt;/span&gt;&lt;span style="color: #008080"&gt; 7&lt;/span&gt; &lt;span style="color: #000000"&gt;                Url &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #800000"&gt;[controller]/[action]/[id]&lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #000000"&gt;,
&lt;/span&gt;&lt;span style="color: #008080"&gt; 8&lt;/span&gt; &lt;span style="color: #000000"&gt;                Defaults &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; { action &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #800000"&gt;Index&lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #000000"&gt;, id &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; (&lt;/span&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;&lt;span style="color: #000000"&gt; },
&lt;/span&gt;&lt;span style="color: #008080"&gt; 9&lt;/span&gt; &lt;span style="color: #000000"&gt;                RouteHandler &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000"&gt;(ShaniRouteHandler)
&lt;/span&gt;&lt;span style="color: #008080"&gt;10&lt;/span&gt; &lt;span style="color: #000000"&gt;            });
&lt;/span&gt;&lt;span style="color: #008080"&gt;11&lt;/span&gt; &lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #008080"&gt;12&lt;/span&gt; &lt;span style="color: #000000"&gt;            RouteTable.Routes.Add(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; Route
&lt;/span&gt;&lt;span style="color: #008080"&gt;13&lt;/span&gt; &lt;span style="color: #000000"&gt;            {
&lt;/span&gt;&lt;span style="color: #008080"&gt;14&lt;/span&gt; &lt;span style="color: #000000"&gt;                Url &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #800000"&gt;Default.aspx&lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #000000"&gt;,
&lt;/span&gt;&lt;span style="color: #008080"&gt;15&lt;/span&gt; &lt;span style="color: #000000"&gt;                Defaults &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; { controller &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #800000"&gt;Home&lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #000000"&gt;, action &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #800000"&gt;Index&lt;/span&gt;&lt;span style="color: #800000"&gt;"&lt;/span&gt;&lt;span style="color: #000000"&gt;, id &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; (&lt;/span&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;&lt;span style="color: #000000"&gt; },
&lt;/span&gt;&lt;span style="color: #008080"&gt;16&lt;/span&gt; &lt;span style="color: #000000"&gt;                RouteHandler &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000"&gt;(ShaniRouteHandler)
&lt;/span&gt;&lt;span style="color: #008080"&gt;17&lt;/span&gt; &lt;span style="color: #000000"&gt;            });
&lt;/span&gt;&lt;span style="color: #008080"&gt;18&lt;/span&gt; &lt;span style="color: #000000"&gt;        }
&lt;/span&gt;&lt;span style="color: #008080"&gt;19&lt;/span&gt; &lt;span style="color: #000000"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;You can see at &lt;em&gt;line 3 &lt;/em&gt;(within the Global.asax)&lt;em&gt;, &lt;/em&gt;this is all I had to do for setting my controller factory as the default factory. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can also think about another good examples on your own, I've found a great post about &lt;a href="http://haacked.com/archive/2007/12/07/tdd-and-dependency-injection-with-asp.net-mvc.aspx"&gt;TDD and Dependency injection with asp.net MVC&lt;/a&gt; by &lt;a href="http://haacked.com/Default.aspx"&gt;Phil Haack&lt;/a&gt; - Read the whole post it is a great one, at the end he is creating his own factory for managing the Control creation using Dependency Injection.&lt;/p&gt;
&lt;p&gt;Enjoy.&lt;/p&gt;&lt;img width="0" height="0" src="http://www.human-debugger.net/blog/aggbug.ashx?id=8737faa4-c281-419a-82bd-019556e49449"/&gt;&lt;/div&gt;</description>
      <comments>http://www.human-debugger.net/blog/CommentView,guid,8737faa4-c281-419a-82bd-019556e49449.aspx</comments>
      <category>.Net 3.5/Asp.net MVC</category>
    </item>
  </channel>
</rss>