<?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>Tallan&#039;s Technology Blog &#187; ASP.NET MVC</title>
	<atom:link href="http://blog.tallan.com/tag/asp-net-mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tallan.com</link>
	<description>Tallan&#039;s Top Technologists Share Their Thoughts on Today&#039;s Technology Challenges</description>
	<lastBuildDate>Mon, 06 Feb 2012 02:15:46 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MIX11 in review</title>
		<link>http://blog.tallan.com/2011/05/06/mix11-in-review/</link>
		<comments>http://blog.tallan.com/2011/05/06/mix11-in-review/#comments</comments>
		<pubDate>Fri, 06 May 2011 05:03:34 +0000</pubDate>
		<dc:creator>Ben Dewey</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[NuGet]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=1146</guid>
		<description><![CDATA[I know this post is overdue, but I&#8217;m happy to say that in the time since MIX has elapsed, my wife and I have sold our condo and moved to a new home.  I&#8217;ve also transition to a new contract, and I am excited to get my feet wet my new project.  Despite [...]]]></description>
			<content:encoded><![CDATA[<p>I know this post is overdue, but I&#8217;m happy to say that in the time since <a href="http://live.visitmix.com">MIX</a> has elapsed, my wife and I have sold our condo and moved to a new home.  I&#8217;ve also transition to a new contract, and I am excited to get my feet wet my new project.  Despite the delay, it was a wonderful experience.  This was my first year at MIX.  The content, announcements, and the networking were all memorable.  I only wish I could&#8217;ve attended all the sessions.  Luckily the content is <a href="http://live.visitmix.com">available online</a>, so I did my best to mark key talks that I wanted to catch back home.</p>
<p>This year was filled with a number of announcements at the two keynotes I did my best to update my <a href="http://twitter.com/bendewey">twitter feed</a> with some of the cool ones.</p>
<p>The <strong>first keynote</strong> was focused around recent release of <strong>IE9</strong>, the next generation of web, <strong>ASP.NET MVC3</strong>, and <strong>HTML5</strong>, and the new release of <strong>IE 10 Platform Preview 1</strong> (<a href="http://channel9.msdn.com/events/mix/mix11/key01">watch online</a>):</p>
<ul>
<li>IE9 Released</li>
<li>IE10 Platform Preview1 Released (<a href="http://ie.microsoft.com/testdrive/">download</a>)</li>
<li>HTML5 Labs <a href="http://html5labs.interoperabilitybridges.com/">available</a> to demonstrate HTML5 features and compatibility</li>
<li>New Developer Conference coming to Anaheim, CA from September 13-16 2011 (PDC maybe? maybe not?)</li>
<li>Microsoft is commited to pushing and actively contributing to <a href="http://nuget.org">NuGet</a> (an open source package manager)</li>
<li>Tools update for ASP.NET MVC 3 available for <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=82cbd599-d29a-43e3-b78b-0f863d22811a">download</a></li>
<li>Entity Framework 4.1 released (<a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b41c728e-9b4f-4331-a1a8-537d16c6acdf&amp;displaylang=en">download</a>)</li>
<li>Updated Scaffolding support for Entity Framework and MVC</li>
<li>Updated ASP.NET MVC New Project Dialog (<a href="http://www.bendewey.com/blog/?attachment_id=348">screenshot</a>) with support for the Razor View engine, HTML5 markup</li>
<li>MVC 3 new projects now include built in <a href="http://www.modernizr.com/">Modernizr</a> script support and many scripts and references are updatable via <a href="http://nuget.org">NuGet</a> package references.</li>
</ul>
<p>The <strong>second keynote</strong>, which really piqued my interests was all about <strong>Windows Phone 7, Silverlight</strong>, and the <strong>Kinect </strong>(<a href="http://channel9.msdn.com/events/mix/mix11/key02">watch</a>):</p>
<ul>
<li>Windows Phone 7
<ul>
<li>Respectable acknowledgement of the Windows Phone 7 Update state by Joe Belfiore, and announcement of the <a href="http://www.microsoft.com/windowsphone/en-us/features/update-schedule-usa.aspx">Where&#8217;s my Update?</a> page.</li>
<li>New Windows Phone 7 Update codenamed &#8220;Mango&#8221; shipping this Fall</li>
<li>Focus of Mango is on Opportunity (Ecosystem, Countries, Discoverability), Capability (Browser, Phone Integration, Multi-tasking), and Developer Experience and Tools</li>
<li>Opportunity
<ul>
<li>Nokia appeared live and affirmed their commitment to partnering with Microsoft to reach hundreds of millions of customers</li>
<li>Mango will support for 16 Languages, 38 Countries, and 35 Countries can buy apps from a single Marketplace</li>
<li>Marketplace search added to App list on home screen</li>
<li>New Pivot view added to App decriptions in Marketplace</li>
<li>New Related Apps pivot on in Marketplace</li>
<li>Hubs and Search Cards (Movies, Restaurants, etc) have an Extras tab that deep links to relevant content</li>
</ul>
</li>
<li>Capability
<ul>
<li>IE9 and HTML5 will be included in the Mango</li>
<li>HTML5 audio/video tag support added</li>
<li>Background Audio support added to Mango</li>
<li>Background Agents available in Mango, with support for running when users battery/wifi are optimal</li>
<li>Multiple Live Tiles for Apps</li>
<li>Live Tile Animation</li>
<li>Updates to Live Tiles without Push notifications</li>
<li>Sensor support added for Direct Camera support, Compass, and Gyro</li>
<li>Socket Communication added</li>
<li>Performance Optimizations &#8211; Scrolling and Input, Image Decode, Garbage Collection, and Memory Usage</li>
<li>New Motion Sensor API for combining the Compass and Gyro raw data</li>
<li>Angry Birds (May 25), Spotify, and Skype are coming to the Windows Phone</li>
</ul>
</li>
<li>Developer Tools
<ul>
<li>Phone orientation tool for simulating Accelerometer, with options for pre-recorded gestures and actions</li>
<li>Location simulation available via built-in Bing Maps tool, with options for pre-recorded location changes</li>
<li>Phone Performance monitoring and analysis tools available</li>
</ul>
</li>
</ul>
</li>
<li>Silverlight
<ul>
<li>Sliverlight 5 Beta is now available (<a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=41c85cc4-de12-4bdb-a60f-f120266e9780&amp;displaylang=en">download</a>)</li>
<li>Expression Blend Preview for Silverlight 5 is now available (<a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=22feb67c-4f65-4ced-97cf-5f8ada296445&amp;displaylang=en">download</a>)</li>
<li>Hardware-Based Video Decode</li>
<li>Added 3D support</li>
<li>Trick Play support &#8211; pitch correction audio</li>
<li>Recieve Commands from a remote control</li>
</ul>
</li>
<li>Kinect
<ul>
<li>Kinect SDK is <a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/">coming this Fall</a></li>
</ul>
</li>
</ul>
<p>In addition to some wonderful keynotes, I wrote a personal summary of the sessions I attended (all of this content is available <a href="http://live.visitmix.com">online</a>):</p>
<ul>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/FRM06">Deconstructing Orchard: Build, Customize, Extend, Ship</a>
<p>Bradley Millington explained the new features of the v1.1 release of Orchard CMS.  This release comes with a new Recipes concept to startup development.  Think Visual Studio Project Templates but for Orchard sites, these are fully customizable and open to community contributions, so new templates may come out for many common scenarios.  Bradley also showed how simple it is to extend modules and themes.  Finally we saw how a simplified deployment can round out a solution with minimal barriers to entry.</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/EXT02">Fonts, Form and Function: A Primer on Digital Typography</a>
<p>Everytime I see Robby Ingebretsen I&#8217;m always so impress about how simple he makes design feel.  Check out his presentation at the <a href="http://www.microsoft.com/design/toolbox/school/">Design Toolbox</a> if you haven&#8217;t yet.  Robby took us on a journey through the font choices for his group&#8217;s new website <a href="http://thinkpixellab.com/">http://thinkpixellab.com/</a>.  He had some musings about fonts having personalities and relating that to a Hollywood cast in a major screenplay.  Of course, we were shown with the every important Grid concept.</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/UXL01">Inspiring UX &#8211; UX Lightning Series</a>
<p>&#8216;UX Lightning sessions are a full hour session with 4 exceptional speakers each presenting 10 minute topics&#8217;. There was lots of inspiring content about Natural User interfaces, putting a lot of ownership on us as Developers and Designers.   August de los Reyes was truly remarkable in his 21st Century Design Manifesto where he promotes a design process which is focused on Motivation, Needs, Positive Emotion, Learnability, Adaptability, and Revolutionary changes. This is in contrast to a user centric design which puts faith in the users (who often don&#8217;t know what, why, and how they like something), and incremental design evolution.</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/EXT13">ECMAScript 5: The New Parts</a>
<p>We had the pleasure of listening to the godfather, Doug Crockford, show off the new ECMAScript 5 changes.  Many of the features have been wanted for some time.  Luckily many of them have shims for older browsers.  The addition of strict mode allows the type safety to bring javascript to the next level of software craftsmanship.</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/DVC18">Multitasking in the Next Version of Windows Phone, Part I</a>
<p>Announced after the second keynote, Darin Miller, reviews the new Background/Live Agents, Reminders, and other background and multi-tasking APIs.  Mango has some great new features, and they are being designed in a way that respects the user, all while retaining their excellent developer experience.  Like optimizing downloads when you are on WiFi and power.</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/FRM05">Building Data-centric N-tier Applications with jQuery</a>
<p>The WCF RIA Services team has been doing a great job rounding out the REST/jQuery story.  Brad Olenick showed a WCF Service that was consumed by jQuery using plugins for templating, data linking, change tracking, sorting and paging on the server side and on the client side.  I can see this being a great tool coupled with the coming jQuery UI Grid.  I hope the community rallies around this one especially with the <a href="http://blog.jquery.com/2011/04/16/official-plugins-a-change-in-the-roadmap/">recent shift in structure</a> for the offical jQuery templating and dataLinking plugins</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/MED06">Graphics &amp; 3D with Silverlight 5</a>
<p>One of most exciting announcements of Silverlight 5 is 3D, I&#8217;m really intrigued by it.  As expected they brought in the XNA 3D features which is more aligned with the Windows Phone 3D experience.   Aaron Oneal wowed everyone with some really cool demos including the Virtual walkthrough of the Windows Cafe.  Then he walked us the through the Graphics processing pipeline showed how vertices, colors, triangles, textures, overlays, and lighting can be written straight to the <a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.graphicsdevice.aspx">GraphicsDevice</a>.  Caution, 3D development is not for yhe faint at heart.</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/FRM14">WCF Web APis: &#8220;There&#8217;s a URI for That&#8221;</a>
<p>Coupled with Brad Olenick work above Glenn Block wrapped up the other side of what&#8217;s included on the <a href="http://wcf.codeplex.com">http://wcf.codeplex.com</a> release.  In addition to consuming json using dynamic objects, they have a fluent API for configuring services and service creation (ie. IoCs). There are also new strongly typed generic request/response wrappers that expose header information.  For more details, see Sam&#8217;s <a href="http://samgentile.com/Web/wcf/the-continuing-evolution-of-wcf-ndash-the-web- uris-evolve/">post</a>.</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/OPN07">Fun with ASP.NET MVC 3 and MEF</a>
<p>The power of NuGet was very prevalent at Mix this year, and I&#8217;m very excited about the power of using MEF and NuGet combined.  Maarten Balliauw showed us how setting up your MVC application to accept MEF Imports, then by separating components into different projects you can add/remove them and in turn on/off functionality.</p>
</li>
<li><a href="http://channel9.msdn.com/events/MIX/MIX11/FRM09">NuGet In Depth: Empowering Open Source on the .NET Platform</a>
<p>Another great HaHaa show.  Scott and Phil performed a great ping-pong over creating and consuming NuGet packages.  They also showed off the new Symbols feature, &#8220;which is huge&#8221; as Scott would say.  Very entertaining session and inspiring for NuGet</p>
</li>
</ul>
<p>During the breaks, I joined up with some other East Coast developers and speakers and worked on a Coding for Fun Project involving the .NET Micro Framework called the <a href="http://www.curiouscloudcontest.com/">Curious Cloud Contest</a>, we had a nice time with the project and we won a Video Production award in the process.  You can see our team&#8217;s (MADExpo) video <a href="http://www.curiouscloudcontest.com/Team.aspx?tid=qyKNaxv397ylTm6rj841gQ%3d%3d">here</a>.</p>
<p>I also had two wonderful evening events, the first night I had the pleasure of joining the Microsoft NUI team for some good Mexican food and the usually HTML5 vs. Silverlight discussion.  The following night I had the privilege of being invited to join the folks from Telerik at Aureole, we were joined by Walt Ritscher and a number of people from the Windows Phone Team including Jamie Rodriguez and Ben Riga, both of whom did a wonderful job presenting at that morning&#8217;s Keynote event.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2011/05/06/mix11-in-review/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What&#8217;s New in ASP.NET MVC 3</title>
		<link>http://blog.tallan.com/2010/12/01/whats-new-in-asp-net-mvc-3/</link>
		<comments>http://blog.tallan.com/2010/12/01/whats-new-in-asp-net-mvc-3/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 18:26:00 +0000</pubDate>
		<dc:creator>Michael Gerety</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[MVC 3]]></category>
		<category><![CDATA[Tech Talk]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2010/12/01/whats-new-in-asp-net-mvc-3/</guid>
		<description><![CDATA[I did a tech talk (an internal presentation for Tallan) on 11/30 with the intent to do a quick demonstration of the new features of ASP.NET MVC3.&#160; Unfortunately (or fortunately, depending on how you look at it), there’s are just too many new features to cover in a 45 minute presentation.
I’m writing a series of [...]]]></description>
			<content:encoded><![CDATA[<p>I did a tech talk (an internal presentation for Tallan) on 11/30 with the intent to do a quick demonstration of the new features of ASP.NET MVC3.&#160; Unfortunately (or fortunately, depending on how you look at it), there’s are just too many new features to cover in a 45 minute presentation.</p>
<p>I’m writing a series of blog posts to get a bit more in-depth on the new features of MVC 3.&#160; I’m going to divide this topic into a number of posts to allow you to pick and choose what to learn about, and to attempt to keep your attention.&#160; All of this in one blog post would be very lengthy and could get boring rather quickly.</p>
<p>In this post, I’ll keep it to a quick summary of the new features and a quick description of each.&#160; We’ll get into more depth in future posts.</p>
<h1>Overview of MVC 3 </h1>
<p>ASP.NET MVC is a wildly popular framework for web application development on the .NET platform, and MVC 3 is the latest iteration (currently in Release Candidate status as of the publication of this article.)</p>
<p>For those of you unfamiliar with the framework, I encourage you to visit the <a href="http://www.asp.net/mvc">Official Microsoft ASP.NET MVC</a> site and take a look.&#160; Anyone who’s been frustrated with web development on the .NET platform up until now will likely find MVC to be a refreshing and exciting change to web development.&#160; ASP.NET MVC truly feels like how web development <em>should have been all along<strong>.&#160; (For those new to MVC or interested in learning MVC in depth, watch this blog for a 10-part screencast series on ASP.NET MVC development, to be completed no later than 12/31/2010).</strong></em></p>
<h2>Some notes on MVC3:</h2>
<ul>
<li>MVC 3 can be installed via the Web Platform Installer or via the Following Link: <a href="http://go.microsoft.com/fwlink/?LinkID=191797">http://go.microsoft.com/fwlink/?LinkID=191797</a> </li>
<li>MVC3 is compatible with MVC2
<ul>
<li>There should be little to no upgrade path for MVC2 apps to work on the framework </li>
<li>Any MVC2 skills and knowledge can be applied to MVC3 development </li>
</ul>
</li>
<li>MVC3 can be installed side-by-side with MVC2 </li>
<li><strong>Important Note: </strong>Unlike previous version the framework, MVC3 <strong><em>requires Visual Studio 2010 and .NET 4.0</em></strong> </li>
</ul>
<h2>What’s New: Feature List</h2>
<p>Below is a categorized list of new features in the MVC3 Framework.&#160; Stay tuned to the <a href="http://blog.tallan.com">Tallan Enterprise Blog</a> for a 4-part screencast series covering all of the enhancements listed here.</p>
<h3>Framework and Tools</h3>
<ul>
<li>Multiple View Engine Support </li>
<li>“Razor” View Engine
<ul>
<li>New Default View Engine </li>
<li>Cleaner/More Concise than Web Forms </li>
<li>Less “ASP” Feel </li>
</ul>
</li>
<li>NuGet Package Management
<ul>
<li>Unix-Like package and dependency management </li>
</ul>
</li>
<li>Common Service Locator library
<ul>
<li>Simplifies Dependency Injection </li>
<li>Adds flexibility to DI and Dependency Resolution </li>
</ul>
</li>
</ul>
<h3>View Enhancements</h3>
<ul>
<li>New Web Helpers
<ul>
<li>Chart Helper </li>
<li>WebGrid Helper </li>
</ul>
</li>
<li>Unobtrusive Javascript and HTML 5
<ul>
<li>jQuery based client-side validation </li>
<li>jQuery based AJAX form and input </li>
</ul>
</li>
</ul>
<h4></h4>
<h3>Controller Enhancements</h3>
<ul>
<li>Global Action Filters </li>
<li>Dynamic ViewModel object </li>
<li>New Action Results
<ul>
<li>HttpNotFoundResult </li>
<li>HttpStatusCodeResult </li>
</ul>
</li>
<li>New Permanent Redirects (HTTP Status Code 301)
<ul>
<li>RedirectPermanent </li>
<li>RedirectToRoutePermanent </li>
<li>RedirectToActionPermanent </li>
</ul>
</li>
<li>Built in JSON Binding Support
<ul>
<li>Action methods support full model-binding from JSON based AJAX requests. </li>
</ul>
</li>
</ul>
<h3>Model Validation Enhancements</h3>
<ul>
<li>New .NET 4 Data Annotations </li>
<li>Improvements to validation attributes
<ul>
<li>Allows for validation based on dependent properties </li>
</ul>
</li>
<li>IValidatableObject interface
<ul>
<li>Model-Level validation </li>
<li>Error-messages related to overall Model State </li>
</ul>
</li>
</ul>
<h4></h4>
<p>&#160;</p>
<p>As each screencast is completed, I will update this post with links to each section.</p>
<p>Stay Tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/12/01/whats-new-in-asp-net-mvc-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://blog.gerety.net/Files/MVC3%20-%20New%20Features%20-%20Part1.mp4" length="86754146" type="video/mp4" />
		</item>
		<item>
		<title>Multi Tenant Architecture via Dependency Injection: Part 3</title>
		<link>http://blog.tallan.com/2010/07/21/multi-tenant-architecture-via-dependency-injection-part-3/</link>
		<comments>http://blog.tallan.com/2010/07/21/multi-tenant-architecture-via-dependency-injection-part-3/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 13:56:01 +0000</pubDate>
		<dc:creator>Nathaniel Engelsen</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[IoC]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=606</guid>
		<description><![CDATA[Using Ninject and Dependency Injection to enhance your ASP.Net MVC application's Multi-Tenant Application.]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://blog.tallan.com/2010/07/11/multi-tenant-architecture-via-dependency-injection-part-1/">Part 1</a> we discussed web application Multi Tenant Architecture, and briefly discussed how dependency injection can allow us to manage our client customizations.  In <a href="http://blog.tallan.com/2010/07/16/multi-tenant-architecture-via-dependency-injection-part-2/">Part 2</a>, we explored how to wire up Ninject to our ASP.Net MVC application and begin to use its dependency injection features.</p>
<p>In Part 3 we will look at how to utilize Ninject&#8217;s features within our application, along with what kind of functionality can be delivered.  At this point, let&#8217;s revisit our goals from Part #1:</p>
<ol>
<li>dynamically set which service object(s) we are using to perform our application logic</li>
<li>dynamically set which view we are returning</li>
<li>dynamically set which partial views we are using</li>
</ol>
<p>Hypothetically, let our application be a standard transactional system, with header records at the top level and child records below it. Furthermore, let it be an order entry system, so we will need to know about quantities, prices, have subtotals, etc.  Our standard interface can be for Work Orders, and look something like the following:</p>
<p>WorkOrders.aspx:<br />
<img src="http://blog.tallan.com/wp-content/uploads/2010/07/work-orders.png" alt="Sample Work Orders Screenshot" /><br />
We have some header information (Work Order #, etc.) and child records, and the ability to interact with the application to modify child records and add new ones.  At this point, a large customer likes what you&#8217;ve done so far and wants to use your application to manage their shop.  But instead of work orders, they need to use Purchase Orders.  You need to make some major modifications without affecting your existing functionality, so you create a new page and use Ninject to inject the right functionality into the application.  Because we implemented Goal #2 in Part 2, we merely need to modify our source repository to provide the PurchaseOrders.aspx page instead of WorkOrders.aspx.</p>
<p>From CompanyConfigProvider.cs:</p>
<pre class="brush: csharp;">
                // construct our list of Views to be used throughout the application
                // for Goals #2 and #3
                foreach (KeyValuePair&lt;string, string&gt; item in r.getViews())
                {
                    cc.Views.Add(item.Key, item.Value);
                }
</pre>
<p>In addition, because these Purchase Orders are between your client and their own customers and not intra-company Work Orders, there are potential tax implications &#8212; as such, you will need to introduce a method of keeping track of tax when necessary.  It will utilize the existing Purchase Orders functionality, but will need to augment it &#8212; the perfect usage of partial views.</p>
<p>TotalNoTax.ascx:</p>
<pre class="brush: csharp;">
&lt;%@ Control Language=&quot;C#&quot; Inherits=&quot;System.Web.Mvc.ViewUserControl&quot; %&gt;
&lt;p&gt;Non-Profit Tax Code: &lt;input type=&quot;text&quot; name=&quot;taxinfo&quot; /&gt;&lt;/p&gt;
</pre>
<p>TotalWithTax.ascx:</p>
<pre class="brush: csharp;">
&lt;%@ Control Language=&quot;C#&quot; Inherits=&quot;System.Web.Mvc.ViewUserControl&quot; %&gt;
&lt;p&gt;Tax Amount: &lt;input type=&quot;text&quot; id=&quot;taxinfo&quot; name=&quot;taxinfo&quot; /&gt;&lt;/p&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    function updateTax() {
        var qty = parseFloat($(&quot;#quantity&quot;).val());
        $(&quot;#taxinfo&quot;).val(qty * 150 * .06);
    }

    $(document).ready(function() {
        $(&quot;#quantity&quot;).blur(updateTax);
        $(&quot;#itemType&quot;).change(updateTax);
    });
&lt;/script&gt;
</pre>
<p>Very simply, we will use jQuery to manage a new form element that will include tax when necessary.  Let&#8217;s start putting it all together.  First, let&#8217;s take a look at our controller:</p>
<p>From OrdersController.cs:</p>
<pre class="brush: csharp;">
using {etc}

namespace MultiTenantNinject.Controllers
{
    [HandleError]
    [ProvideCompanyConfig]
    public class OrdersController : Controller
    {
</pre>
<p>As you can see, we inherit from Controller like normal and utilize our ProvideCompanyConfig attribute so that we can be assured we have access to our company config upon rendering.  Let&#8217;s take a look at an Action:</p>
<pre class="brush: csharp;">
        public ActionResult Index()
        {
            ViewResult v = View(_companyConfig.Views[&quot;Order Management&quot;]);

			// add view data items for the header and children;

			// add item to be used for determining if it's a taxable or non-taxable transaction:
			v.ViewData.add(&quot;taxState&quot;,repository.TaxState);

            return v;

        }
</pre>
<p>The first step in rendering the View to the user is ensuring we have an &#8220;Order Management&#8221; entry in our Views collection that establishes what type of major functionality to use.  Our repository would load the config file with a text entry like &#8220;WorkOrders&#8221; or &#8220;PurchaseOrders&#8221; to correspond with &#8220;WorkOrders.aspx&#8221; or &#8220;PurchaseOrders.aspx&#8221;, respectively.  We can set our ViewData at this point, perhaps using a service object (which we will explore soon) and then return the view.  At this point, we have a solid understanding of achieving Goal #2, so let&#8217;s take a look at the few lines necessary to achieve Goal #3:</p>
<p>From PurchaseOrders.aspx:</p>
<pre class="brush: csharp;">
    &lt;% var configSettings = (MultiTenantNinject.Models.ICompanyConfig)ViewData[&quot;companyConfigSettings&quot;];  %&gt;
	&lt;h3&gt;Purchase Orders&lt;/h3&gt;
	... etc ...
    &lt;p&gt;&lt;% Html.RenderPartial(configSettings.Views[string.Format(&quot;Taxes_{0}&quot;,ViewData[&quot;taxState&quot;])]); %&gt;
</pre>
<p>By utilzing the correct entry in our repository for the user&#8217;s state, we can provide the correct tax functionality.  If the company&#8217;s location was in Florida, the repository could provide &#8220;TotalWithTax&#8221; for the &#8220;Taxes_FL&#8221; binding, and &#8220;TotalNoTax&#8221; for the other states.  Obviously we can take it up a level of abstraction and determine whether or not this transaction is taxable in the controller or service object, but this serves as an adequate example of Goal #3.  Lastly, let&#8217;s take a look at our solution for Goal #1 &#8212; it&#8217;s all well and good when we can provide custom front-end functionality for our users, but at some point we will need to implement logic and manipulate data.  Let&#8217;s revisit the module where we inject our services:</p>
<p>From OrderModule.cs:</p>
<pre class="brush: csharp;">
        public override void Load()
        {
            // use reflection to bind a list of types (from our Config's &quot;Bindings&quot; collection)
            // to be used when called upon during injection
            string serviceLocationPrefix = &quot;MultiTenantNinject.Services.&quot;;
            foreach (KeyValuePair&lt;string,string&gt; item in _config.Bindings)
            {
                Bind(Type.GetType(serviceLocationPrefix + item.Key)).To(Type.GetType(serviceLocationPrefix + item.Value));
            }
        }
</pre>
<p>We will need to provide an interface and an implementation for our service(s).  Firstly, the interface:</p>
<pre class="brush: csharp;">
IOrderService.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Web.Mvc;

namespace MultiTenantNinject.Services
{
    public interface IOrderService
    {
        string Process(ViewDataDictionary viewdata);
        DataTable Orders { get; set; }
    }
}
</pre>
<p>and one of the implementations:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.Mvc;

namespace MultiTenantNinject.Services
{
    public class VideoCardOrderService: IOrderService
    {

        #region IService Members

        public string Process(ViewDataDictionary viewdata)
        {
            // here we do transactions pertaining to video cards
            return &quot;Thanks for buying a video card!&quot;;
        }

        #region Orders
        private DataTable _Orders;
        public DataTable Orders
        {
            get
            {
                return _Orders;
            }
            set
            {
                if (_Orders == value) return;
                _Orders = value;
            }
        }
        #endregion

        #endregion

    }
}
</pre>
<p>Service objects can perform most of the functionality of your application, and do not need to be gone over in great detail, as they are as varied as anything else can be.  Suffice it to say that it&#8217;s a standard interface/implementation pattern of development.  Ninject allows you to set it up for injection, as we did in Part 2, so that whenever you call a particular interface for this user a particular implementation is used.  &#8220;VideoCardOrderService&#8221; could easily be &#8220;MotherboardOrderService&#8221; or &#8220;CarOrderService&#8221;:</p>
<p>From OrdersController.cs:</p>
<pre class="brush: csharp;">
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Save()
        {
            _orderService.Process(ViewData);
            return new RedirectResult(&quot;Index&quot;);
        }
</pre>
<p>Our controller, in the end, is completely agnostic of our major functionality, our minor (partial view) functionality, and our domain logic:</p>
<p>OrdersController.cs:</p>
<pre class="brush: csharp;">
using {etc}
using Ninject;

namespace MultiTenantNinject.Controllers
{
    [HandleError]
    [ProvideCompanyConfig]
    public class OrdersController : Controller
    {
        ICompanyConfig _companyConfig;
        IOrderService _orderService;

        public OrdersController(ICompanyConfig pCompanyConfig, IOrderService pOrderService)
        {
            _companyConfig = pCompanyConfig;
            _orderService = pOrderService;
        }

        public OrdersController()
        {
        }

        public ActionResult Index()
        {
            ViewResult v = View(_companyConfig.Views[&quot;Order Management&quot;]);

			// add view data items for the header and children;

			// add item to be used for determining if it's a taxable or non-taxable transaction:
			v.ViewData.add(&quot;taxState&quot;,repository.TaxState);

            return v;
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Save()
        {
            _orderService.Process(ViewData);
            return new RedirectResult(&quot;Index&quot;);
        }
    }
}
</pre>
<p>Thus, the conclusion to our series about utilizing dependency injection within ASP.Net MVC to enhance a Multi-Tenant Architecture.  We can provide service objects without our controller (or anything else) performing logic switches, we can provide major changes to functionality without creating a new codebase, and we can provide in-place customizations truly in-place.  In addition, we&#8217;ve created our application such that we can utilize any kind of data layer or repository and we can utilize testing frameworks to test our code without having to rewrite anything.  And lastly, although it&#8217;s taken a moderate level of effort to get to this point, we can be secure in the knowledge that additional changes can be implemented without affecting existing functionality, and we can easily swap out functionality when the situation arises with very little additional effort.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/07/21/multi-tenant-architecture-via-dependency-injection-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multi Tenant Architecture via Dependency Injection: Part 2</title>
		<link>http://blog.tallan.com/2010/07/16/multi-tenant-architecture-via-dependency-injection-part-2/</link>
		<comments>http://blog.tallan.com/2010/07/16/multi-tenant-architecture-via-dependency-injection-part-2/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 12:37:17 +0000</pubDate>
		<dc:creator>Nathaniel Engelsen</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[IoC]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=570</guid>
		<description><![CDATA[Using Ninject and Dependency Injection to enhance your ASP.Net MVC application's Multi-Tenant Application.]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://blog.tallan.com/2010/07/11/multi-tenant-architecture-via-dependency-injection-part-1/">Part 1</a> we discussed Multi Tenant Architecture as it pertains to web development, along with how dependency injection (specifically with Ninject) can allow us to manage our necessary customizations a bit cleaner.</p>
<p>To start off with, let&#8217;s talk about using Ninject with ASP.Net MVC.  You&#8217;ll need to download the appropriate Ninject version for your .NET framework.  Our example will use Ninject 2.0 with ASP.Net MVC 1.  Download Ninject from the homepage at <a href="http://ninject.org/">http://ninject.org/</a> and visit the <a href="http://ninject.org/learn">dojo</a> and <a href="http://wiki.github.com/ninject/ninject/">github</a> to learn the basics. Ninject will manage our controllers for us (it needs to, so it can monitor for injection points) and so will need to be tightly integrated into our application.  For starters, we&#8217;re going to need to change our global.asax.cs file.  Take a look:</p>
<p>Global.asax.cs:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Ninject.Web.Mvc;
using Ninject;
using Ninject.Modules;
using MultiTenantNinject.Controllers.Components;
using MultiTenantNinject.Models;

namespace MultiTenantNinject
{
  // Inherit from NinjectHttpApplication instead of HttpApplication
  public class MvcApplication : NinjectHttpApplication
  {
    public static void RegisterRoutes(RouteCollection routes)
    {
      routes.IgnoreRoute(&quot;{resource}.axd/{*pathInfo}&quot;);

      // hack for visual studio's web server
      routes.IgnoreRoute(&quot;{*favicon}&quot;, new { favicon = @&quot;(.*/)?favicon.ico(/.*)?&quot; });

      routes.MapRoute(
        &quot;Default&quot;, // Route name
        &quot;{controller}/{action}/{id}&quot;, // URL with parameters
        new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = &quot;&quot; } // Parameter defaults
      );

    }

    // we use OnApplicationStarted, because Ninject is using Application_Started
    protected override void OnApplicationStarted()
    {
      // no big surprise here -- register our routes.
      RegisterRoutes(RouteTable.Routes);
      // register every controller in our application for injection
      RegisterAllControllersIn(Assembly.GetExecutingAssembly());
    }

    // this is called automatically from within the Ninject framework
    protected override IKernel CreateKernel()
    {
      // create a Kernel to manage injections.
      // have the Kernel process our &quot;SetupModule&quot; class
      IKernel k = new StandardKernel(new SetupModule());
      // have the Kernel process our &quot;ConfigModule&quot; class
      k.Load(new ConfigModule());
      // have the Kernel process our &quot;OrderModule class
      // pass an instance of our company config that our ConfigModule calls for
      k.Load(new OrderModule(k.Get&lt;ICompanyConfig&gt;()));
      return k;
    }
  }
}
</pre>
<p>You can see how the CreateKernel() method loads a number of Modules to manage our Dependency Injection.  Let&#8217;s take a look at these modules. The first module to investigate will provide bindings for our .NET MVC dependencies.</p>
<p>SetupModule.cs:</p>
<pre class="brush: csharp;">
using {etc}
using Ninject;
using Ninject.Modules;
using Ninject.Web.Mvc;

namespace MultiTenantNinject.Controllers.Components
{
    // inherit from NinjectModule
    public class SetupModule : NinjectModule
    {
        // NinjectModule is an implementation of the Strategy design pattern and must implement &quot;Load()&quot;
        public override void Load()
        {
            // Let's inject .NET MVC framework dependencies, wow!
            Bind&lt;IFormsAuthentication&gt;()
                .To&lt;FormsAuthenticationService&gt;();
            Bind&lt;IMembershipService&gt;()
                .To&lt;AccountMembershipService&gt;();
            Bind&lt;MembershipProvider&gt;()
                .ToMethod(ctx =&gt; Membership.Provider);
        }
    }
}
</pre>
<p>Our next module will bind the heart of our Multi Tenant Architecture, the &#8220;Company Config&#8221;. This configuration object will be lightweight, cached server-side (ideally once for each company) and will be available during most operations of the page lifecycle.</p>
<p>ICompanyConfig.cs:</p>
<pre class="brush: csharp;">
using {etc}

namespace MultiTenantNinject.Models
{
    public interface ICompanyConfig
    {
        // Task #1 -- provide service objects
        Dictionary&lt;string, string&gt; Bindings { get; set; }
        // Task #2 &amp; #3 -- provide views and partial views
        Dictionary&lt;string, string&gt; Views { get; set; }

        String CompanyName { get; set; }

    }
}
</pre>
<p>ConfigModule.cs:</p>
<pre class="brush: csharp;">
using {etc}

namespace MultiTenantNinject.Controllers.Components
{
    public class ConfigModule : NinjectModule
    {
        public override void Load()
        {
            // Ninject.Activation.Provider is a factory object.
            CompanyConfigProvider Provider = new CompanyConfigProvider(WebConfigurationManager.AppSettings);

            // Bind our service (ICompanyConfig) to its implementation using the
            // aforementioned Provider.  Bind it so that each request uses the same
            // instance of the service.
            Bind&lt;ICompanyConfig&gt;()
                .ToProvider(Provider)
                .InRequestScope();

        }
    }
}
</pre>
<p>Our next module will control the functionality for our example customizations revolving around Purchase Orders.  In practice we could have multiple modules, perhaps one for each functional area of our application, but our single module will serve our purposes here:</p>
<p>OrderModule.cs:</p>
<pre class="brush: csharp;">
using {etc}

namespace MultiTenantNinject.Controllers.Components
{
    public class OrderModule : NinjectModule
    {
        private readonly ICompanyConfig _config;

        // We see our first &quot;Inject&quot; attribute.
        // Here we will take an instance of our company config
        // and later use it to bind our application services
        [Inject]
        public OrderModule(ICompanyConfig companyConfig)
        {
            _config = companyConfig;
        }

        public override void Load()
        {
            // use reflection to bind a list of types (from our Config's &quot;Bindings&quot; collection)
            // to be used when called upon during injection
            string serviceLocationPrefix = &quot;MultiTenantNinject.Services.&quot;;
            foreach (KeyValuePair&lt;string,string&gt; item in _config.Bindings)
            {
                Bind(Type.GetType(serviceLocationPrefix + item.Key)).To(Type.GetType(serviceLocationPrefix + item.Value));
            }
        }
    }
}
</pre>
<p>Let&#8217;s briefly revisit our goals from Part #1:</p>
<ol>
<li>dynamically set which service object(s) we are using to perform our application logic</li>
<li>dynamically set which view we are returning</li>
<li>dynamically set which partial views we are using</li>
</ol>
<p>At this point we can see the pattern unfolding.  We use our Modules to dictate to the Kernel what strategies to use when binding implementations to our services.  We can use reflection, we can use strings and types, and we can use Providers inside of our Modules during binding.  We will be coming back to OrderModule.cs, as that is part of our implementation for Goal #1.  Let us take a look now at our Provider from our ConfigModule:</p>
<p>CompanyConfigProvider.cs:</p>
<pre class="brush: csharp;">
using {etc}
using Ninject.Activation;

namespace MultiTenantNinject.Models
{
    // inherit from Ninject.Activation.Provider
    public class CompanyConfigProvider: Provider&lt;CompanyConfig&gt;
    {
        // these settings are provided by our web.config in this example
        public CompanyConfigProvider(NameValueCollection settings)
        {
            Settings = settings;
        }

        protected NameValueCollection Settings { get; set; }

        // build and return an instance of our CompanyConfig using the specific context
        // IProvider is a Factory that will have its CreateInstance() method called
        // the first time that a CompanyConfig is injected
        protected override CompanyConfig CreateInstance(IContext context)
        {
            // use a caching mechanism to store our company config.  we cannot
            // cache in the Application cache because we have a Multi Tenant Application.
            // we can use Session in a pinch, although depending on your application's traffic,
            // you might need to use something else
            System.Web.SessionState.HttpSessionState Session = HttpContext.Current.Session;
            CompanyConfig cc = null;

            // if we don't have a cached company config:
            if (Session == null || Session[&quot;cc&quot;] == null)
            {
                cc = new CompanyConfig();
                // our repository is extremely unsophisticated, but you should
                // get the idea of how this works.  it may very well be passed in
                // via constructor injection
                MultiTenantNinject.Models.Repository r = new Repository();

                // construct our list of Views to be used throughout the application
                // for Goals #2 and #3
                foreach (KeyValuePair&lt;string, string&gt; item in r.getViews())
                {
                    cc.Views.Add(item.Key, item.Value);
                }
                // construct our list of service bindings to be used throughout the application
                // for Goal #1 (previously seen in OrderModule.cs
                foreach (KeyValuePair&lt;string, string&gt; item in r.getBindings())
                {
                    cc.Bindings.Add(item.Key, item.Value);
                }
                // if we can cache our company config:
                if (Session != null &amp;&amp; Session[&quot;cc&quot;] == null)
                {
                    Session[&quot;cc&quot;] = cc;
                }
                // set company name (normally would be from the repository)
                cc.CompanyName = &quot;Widgets, Inc.&quot;;
            }
            else  // we have a previously cached company config
            {
                cc = (CompanyConfig)Session[&quot;cc&quot;];
            }

            return cc;
        }
    }
}
</pre>
<p>To make our lives a little easier and yet more structured, let&#8217;s create an ActionFilterAttribute to inject our CompanyConfig into our Views:</p>
<p>From ProvideCompanyConfigAttribute:</p>
<pre class="brush: csharp;">
    public class ProvideCompanyConfigAttribute : ActionFilterAttribute
    {
        [Inject]
        public ICompanyConfig Settings { get; set; }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            filterContext.Controller.ViewData.Add(&quot;companyConfigSettings&quot;, Settings);
        }
    }
</pre>
<p>We use Ninject&#8217;s &#8220;Inject&#8221; attribute to provide the CompanyConfig to our Attribute, and then inject the config into the controller as a matter of course.</p>
<p>At this point we&#8217;ve seen how Ninject positions itself within our application (a controller factory and application superclass) and how we can use Ninject&#8217;s modularity to manage our bindings.  We&#8217;ve touched upon Goals #1, 2, and 3, and can see it taking shape before us.  We have a company configuration that encapsulates the customizations for the currently logged in user and provides the customized bindings and views for that logged in user.  We have basically everything we need to begin working with our customized functionality.</p>
<p>To get this far we have made the following assumptions:</p>
<ol>
<li>Your repository works.</li>
<li>You have an ASP.Net MVC application in otherwise working order.</li>
<li>You have downloaded and referenced the Ninject libraries.</li>
</ol>
<p>In Part 3 we will look at our application controllers and views, and then explore what we can do to provide customized functionality to our users.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/07/16/multi-tenant-architecture-via-dependency-injection-part-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Multi Tenant Architecture via Dependency Injection: Part 1</title>
		<link>http://blog.tallan.com/2010/07/11/multi-tenant-architecture-via-dependency-injection-part-1/</link>
		<comments>http://blog.tallan.com/2010/07/11/multi-tenant-architecture-via-dependency-injection-part-1/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 20:51:34 +0000</pubDate>
		<dc:creator>Nathaniel Engelsen</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[IoC]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=421</guid>
		<description><![CDATA[Discover how to use Inversion of Control and Dependency Injection to enhance your web application's Multi-Tenant Application.]]></description>
			<content:encoded><![CDATA[<p>Chances are, if you&#8217;ve been developing web applications for a number of years, you&#8217;ve noticed a few ways of provisioning your application for your users.</p>
<ol>
<li>Your users all log into a single codebase.  It might be load balanced, cached, the whole nine yards, but everybody is on the same build and accesses the same data.</li>
<li>Your users log into multiple codebases and/or multiple databases.  Perhaps you have some high-powered customers who want custom functionality, and so you forked your codebase and created them their own functionality.   Most likely, you can update your customer&#8217;s builds independently of one another.</li>
<li>Your users all log into a single codebase, but you use flags, connection strings, config files, etc., to logically separate out your users from one another.  Your high-powered customers see their custom functionality, but it&#8217;s part of the main codebase and you are able to update your application in one fell swoop.</li>
</ol>
<p>We&#8217;re going to talk more about option #3 &#8212; the Multi-Tenant Architecture.  There is <a href="http://lmgtfy.com/?q=multi+tenant+architecture">PLENTY of reading material</a> out there for you to learn more about multi-tenancy.  Suffice it to say that it allows you to satisfy multiple sets of requirements for your multiple customers via one codebase, and your customers, most likely, are logically separate in the database(i.e. they use one schema and one top-level data store) instead of physically separate.</p>
<p>In the past, (and present, for novice developers), it was a usual practice to utililze config files, database flags, etc., to turn on and off functionality. Your code may have looked something like:</p>
<pre class="brush: csharp;">
&lt;% if (showThisFunctionality) %&gt;
&lt;-- this widget is shown --&gt;;
&lt;% else %&gt;;
&lt;-- this other widget is shown --&gt;
&lt;% end if %&gt;
</pre>
<p><strong>Fig 1: Classic ASP</strong></code></p>
<p>By utilizing a dependency injection framework you can provide features to your users, based on configuration and setup, without having to use logic switches inside of your application.  This is above and beyond the existing benefits of using a dependency injection framework, which is not the scope of this essay but can be enumerated <a href="http://misko.hevery.com/2009/01/14/when-to-use-dependency-injection/">here</a>, for instance.  Our example will use <a href="http://ninject.org/">Ninject</a> and ASP.NET MVC, although you could use any DI and application frameworks.</p>
<p>Our challenge for this example will be to:</p>
<ol>
<li>dynamically set which service object(s) we are using to perform our application logic</li>
<li>dynamically set which view we are returning</li>
<li>dynamically set which partial views we are using</li>
</ol>
<p>Our example will utilize dependency injection to provide order fulfillment functionality for our customers.  For goal #1, we will use Ninject's MVC integration to provide service objects for our controllers.  Once Ninject is wired up, we can have our service objects perform our application logic against our Model, and as a matter of fact, Behavioral design patterns are a good fit here.  Goal #2 is achievable fairly easily with ASP.Net MVC.  Setting which view you're returning via any MVC framework is often a very simple operation and comes down to returning a string variable which represents the view in question.  For ASP.NET MVC we can '<code><span style="color: #0000ff">return</span><span>View(</span><span style="color: #a31515">"viewName"</span><span>)'</span></code> where "viewName" is the name of the view we wish to return.  There is also the obvious <code>"<span style="color: #0000ff">return </span><span>View(viewNameVariable)</span>"</code> override.  Our example will use a configuration object to set which view is being called.  Accomplishing goal #3 can be thought of as an extension of #2, but "finer grained". Where you have general and reusable functionality within your view, your partial views allow you to have specific customizations exposed to your user in a consistent fashion.</p>
<p>In Part 2 we will investigate both integrating Ninject with ASP.Net MVC as well as what shape our framework will take.  In Part 3 we will finish up our framework architecture and explore how to use it to provide features to our users.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/07/11/multi-tenant-architecture-via-dependency-injection-part-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Handle asp.net MVC session expiration</title>
		<link>http://blog.tallan.com/2010/06/25/handle-asp-net-mvc-session-expiration/</link>
		<comments>http://blog.tallan.com/2010/06/25/handle-asp-net-mvc-session-expiration/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 02:26:47 +0000</pubDate>
		<dc:creator>Craig Vallee</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2010/06/25/handle-asp-net-mvc-session-expiration/</guid>
		<description><![CDATA[Here is a really simple way to handle a session expiration in asp.net MVC using a base controller.  Having all controller inherit from a basecontoller and overriding the OnActionExecuting event allows for checking the session before all actions are executed.
Here is the code

public class BaseController : Controller

{

    protected override void OnActionExecuting

  [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a really simple way to handle a session expiration in asp.net MVC using a base controller.  Having all controller inherit from a basecontoller and overriding the OnActionExecuting event allows for checking the session before all actions are executed.</p>
<p>Here is the code</p>
<pre style="border: 1px solid #cecece;width: 650px;overflow: auto;background-color: #fbfbfb;padding: 5px">
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> BaseController : Controller
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">{
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> OnActionExecuting
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">        (ActionExecutingContext filterContext)
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">    {
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">        <span style="color: #008000">// If session exists</span>
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">        <span style="color: #0000ff">if</span> (filterContext.HttpContext.Session != <span style="color: #0000ff">null</span>)
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">        {
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">            <span style="color: #008000">//if new session</span>
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">            <span style="color: #0000ff">if</span> (filterContext.HttpContext.Session.IsNewSession)
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">            {
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                <span style="color: #0000ff">string</span> cookie =
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                    filterContext.HttpContext.Request.Headers["<span style="color: #8b0000">Cookie</span>"];
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                <span style="color: #008000">//if cookie exists and sessionid index is greater than zero</span>
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                <span style="color: #0000ff">if</span> ((cookie !=<span style="color: #0000ff">null</span>) &amp;&amp;
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                    (cookie.IndexOf("<span style="color: #8b0000">ASP.NET_SessionId</span>") &gt;= 0))
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                {
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                    <span style="color: #008000">//redirect to desired session </span>
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                    <span style="color: #008000">//expiration action and controller</span>
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                    filterContext.Result =
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                        RedirectToAction("<span style="color: #8b0000">SessionExpired</span>", "<span style="color: #8b0000">Home</span>");
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                    <span style="color: #0000ff">return</span>;
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">                }
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">            }
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">        }
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">        <span style="color: #008000">//otherwise continue with action</span>
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">        <span style="color: #0000ff">base</span>.OnActionExecuting(filterContext);
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">    }
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">}
</pre>
<pre style="background-color: #fbfbfb;font-family: consolas,'Courier New',courier,monospace;font-size: 12px;width: 100%;margin: 0em">}
</pre>
</pre>
<p>This simple but effective method ensures that no actions will be executed if the session has expired forcing the user to login again</p>
<p>-Craig</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/06/25/handle-asp-net-mvc-session-expiration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC Primer &#8211; Presentation Materials</title>
		<link>http://blog.tallan.com/2010/06/23/asp-net-mvc-primer-presentation-materials/</link>
		<comments>http://blog.tallan.com/2010/06/23/asp-net-mvc-primer-presentation-materials/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 16:09:54 +0000</pubDate>
		<dc:creator>Michael Gerety</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[User Groups]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Code Camp]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2010/06/23/asp-net-mvc-primer-presentation-materials/</guid>
		<description><![CDATA[Here are the links to the material from the ASP.NET MVC 2 Primer presentation given at the 3rd Annual Hartford Code Camp on Saturday, June 19, 2010:
Powerpoint Slides: Primer.pptx
Source Code: PrimerDemoSource.zip
Disclaimer:
I have done some Very Bad Things™ in this code in order to speed up the presentation that are always considered bad practice.&#160;&#160; The most [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the links to the material from the ASP.NET MVC 2 Primer presentation given at the 3rd Annual Hartford Code Camp on Saturday, June 19, 2010:</p>
<p>Powerpoint Slides: <a href="http://blog.gerety.net/Files/Presentations/MVC/Primer/primer.pptx">Primer.pptx</a></p>
<p>Source Code: <a href="http://blog.gerety.net/Files/Presentations/MVC/Primer/PrimerDemoSource.zip">PrimerDemoSource.zip</a></p>
<h2>Disclaimer:</h2>
<p>I have done some Very Bad Things™ in this code in order to speed up the presentation that are always considered bad practice.&#160;&#160; The most egregious violation of best practices is the inclusion of the data access code in the controller’s action methods.&#160; Please do not use this code as a basis for your application design, especially when it comes to best practices.&#160; My next post will include the information covered in the advanced section along with a lot of material we never got to.&#160; This will be a much better demonstration of proper design.</p>
<p>Also, look for upcoming screencasts on ASP.NET MVC2 and other development topics posted here and/or on my personal blog at <a href="http://blog.gerety.net">http://blog.gerety.net</a> , which should be up and running in the next few days.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/06/23/asp-net-mvc-primer-presentation-materials/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>S#arp Architecture</title>
		<link>http://blog.tallan.com/2010/06/20/sarp-architecture/</link>
		<comments>http://blog.tallan.com/2010/06/20/sarp-architecture/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 05:32:13 +0000</pubDate>
		<dc:creator>Lee Rodgers</dc:creator>
				<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[nHibernate]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2010/06/20/sarp-architecture/</guid>
		<description><![CDATA[I have been doing some work and research with ASP.NET MVC 2.0.  My first interest was to try to figure out how to get Dependency Injection working with ASP.NET.  I started doing investigating how to link in Springframework.net.  This direction led me down a track that required some manual configuration.  This is when i found [...]]]></description>
			<content:encoded><![CDATA[<p>I have been doing some work and research with <a href="http://www.asp.net/mvc" target="_blank">ASP.NET MVC 2.0</a>.  My first interest was to try to figure out how to get <a href="http://en.wikipedia.org/wiki/Dependency_injection" target="_blank">Dependency Injection</a> working with ASP.NET.  I started doing investigating how to link in <a href="http://springframework.net" target="_blank">Springframework.net</a>.  This direction led me down a track that required some manual configuration.  This is when i found <a href="http://sharparchitecture.net/" target="_blank">S#arp Architecture</a>, which I found very interesting since it gave you the benefits without the configuration up front.</p>
<p><a href="http://sharparchitecture.net/" target="_blank">S#arp Architecture</a> is a project template for Visual Studio that will set you up with a ASP.NET MVC application that is already wired up for Dependency Injection and using <a href="http://community.jboss.org/wiki/NHibernateforNET" target="_blank">nHibernate</a> for data access.  more information can be found on the S#arp Architecture website and wiki.</p>
<p>My findings so far have been very positive.  Within about 45 minutes I had a web application with some basic CRUD functionality.  This functionality included unit testing at every layer.  It seems like a great way to start a project and easily promote best practices like dependency injection and test driven development.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/06/20/sarp-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC presentation materials from Code Camp 10</title>
		<link>http://blog.tallan.com/2008/10/02/aspnet-mvc-presentation-materials-from-code-camp-10/</link>
		<comments>http://blog.tallan.com/2008/10/02/aspnet-mvc-presentation-materials-from-code-camp-10/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 20:50:49 +0000</pubDate>
		<dc:creator>Max Weber</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Code Camp]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/?p=57</guid>
		<description><![CDATA[Hi all,
Acouple of weekends ago at Code Camp 10, I presented on the ASP.NET Model View Controller (MVC) Framework. As promised, I have attached the presentation for all to see.
I would like to thank my co-worker Stan Kennedy for his assistance with the slide deck (actually, he deserves most, if not all of the credit [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>Acouple of weekends ago at Code Camp 10, I presented on the ASP.NET Model View Controller (MVC) Framework. As promised, I have attached the presentation for all to see.</p>
<p>I would like to thank my co-worker Stan Kennedy for his assistance with the slide deck (actually, he deserves most, if not all of the credit for it) and everyone that showed up to the presentation. I hope everyone learned something &#8211; I certainly did as well.</p>
<p>I would like to direct everyone over to the <a href="http://www.asp.net/mvc">ASP.NET MVC site</a>, which is an excellent resource for anyone wanting to know more about it &#8211; and would recommend anyone who wants to start out with it to view Stephen Walther&#8217;s How-to videos on the subject (also on the ASP.NET MVC site) as well.</p>
<p>Additionally, I know there were some questions around REST and what it had to do with the Model View Controller. From what I understand, REST is simply an architectural style, which is usually applied to an entire website. REST stands for Representational State Transfer and in the case of a website, each page represents a state, and each link represents a state transfer. Since each page is its own state, the state transfer takes place by loading up a new URL on the page. The ASP.NET MVC Framework allows a developer to build their website in a RESTful architecture from the ground up from the framework&#8217;s normal usage patterns. There is a bit more to the architecture, so for the curious, I would recommend heading to wikipedia to get additional information or to <a href="http://www.xfront.com/REST-Web-Services.html">this other site</a>, which I think summarizes REST quite well.</p>
<p>Thanks, and enjoy</p>
<p>Max</p>
<p>Powerpoint slides: <a href="http://blog.tallan.com/wp-content/uploads/2008/10/mvc-mweber-code-camp-10.ppt">mvc-mweber-code-camp-10</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2008/10/02/aspnet-mvc-presentation-materials-from-code-camp-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

