<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Dependency Injection in ASP.NET MVC: Contextual controller injection</title>
	<atom:link href="http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Fri, 17 May 2013 09:02:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: jrnail23</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2366</link>
		<dc:creator>jrnail23</dc:creator>
		<pubDate>Wed, 08 Sep 2010 17:24:43 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2366</guid>
		<description>Hi Jimmy,
I used this approach quite successfully, along with other examples you provided in this series on a recent project (MVC 2), and now that MVC 3 Preview 1 is upon us, can you provide some insight as to how you might use nested containers within their Service Locator approach?  

Brad Wilson suggests this (http://bradwilson.typepad.com/blog/2010/07/service-location-pt1-introduction.html#comment-6a00e54fbd8c498834013485c687f2970c):
&quot;depending on the context of the request, you could write a CSL implementation that is context aware and can automatically spin up nested containers based on the context. For example, if your strategy was to spin up a nested container per request, your CSL implementation could do that on your behalf, and work alongside an HTTP module which automatically cleaned up those containers when the request went out of scope. You&#039;d still get your per-request containers while supporting the CSL.&quot;

Do you have any thoughts on how I might go about this with StructureMap, or if it&#039;s even a desirable course of action in the first place?</description>
		<content:encoded><![CDATA[<p>Hi Jimmy,<br />
I used this approach quite successfully, along with other examples you provided in this series on a recent project (MVC 2), and now that MVC 3 Preview 1 is upon us, can you provide some insight as to how you might use nested containers within their Service Locator approach?  </p>
<p>Brad Wilson suggests this (<a href="http://bradwilson.typepad.com/blog/2010/07/service-location-pt1-introduction.html#comment-6a00e54fbd8c498834013485c687f2970c" rel="nofollow">http://bradwilson.typepad.com/blog/2010/07/service-location-pt1-introduction.html#comment-6a00e54fbd8c498834013485c687f2970c</a>):<br />
&#8220;depending on the context of the request, you could write a CSL implementation that is context aware and can automatically spin up nested containers based on the context. For example, if your strategy was to spin up a nested container per request, your CSL implementation could do that on your behalf, and work alongside an HTTP module which automatically cleaned up those containers when the request went out of scope. You&#8217;d still get your per-request containers while supporting the CSL.&#8221;</p>
<p>Do you have any thoughts on how I might go about this with StructureMap, or if it&#8217;s even a desirable course of action in the first place?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taber</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2365</link>
		<dc:creator>Taber</dc:creator>
		<pubDate>Tue, 04 May 2010 21:05:36 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2365</guid>
		<description>Im new to MVC and Structuremap and am implementing this concept to proivde the requestContext to other objects as needed. 
In my app I have many controllers deriving from one or more other controllers; I have tried but cant figure out a way to wireup IFooService on the baseController instead of all the inherited controllers.. is it even possible ??</description>
		<content:encoded><![CDATA[<p>Im new to MVC and Structuremap and am implementing this concept to proivde the requestContext to other objects as needed.<br />
In my app I have many controllers deriving from one or more other controllers; I have tried but cant figure out a way to wireup IFooService on the baseController instead of all the inherited controllers.. is it even possible ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2364</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Mon, 03 May 2010 12:45:28 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2364</guid>
		<description>@jesus

Whoops, just an oversight that I left that out:

private static readonly object _nestedContainerKey = new object();

Just a private field in the controller factory.

@Maxime

I&#039;ve never developed/shipped an app with FubuMVC, but I have with MVC, so I can&#039;t really talk about Fubu other than I really like what I see and I steal ideas on a regular basis.  My suggestion would be to spike out a solution with Fubu and ASP.NET MVC 2, and see which one suits you better.  After that, it&#039;s really just up to you and your team&#039;s comfort level on OSS.</description>
		<content:encoded><![CDATA[<p>@jesus</p>
<p>Whoops, just an oversight that I left that out:</p>
<p>private static readonly object _nestedContainerKey = new object();</p>
<p>Just a private field in the controller factory.</p>
<p>@Maxime</p>
<p>I&#8217;ve never developed/shipped an app with FubuMVC, but I have with MVC, so I can&#8217;t really talk about Fubu other than I really like what I see and I steal ideas on a regular basis.  My suggestion would be to spike out a solution with Fubu and ASP.NET MVC 2, and see which one suits you better.  After that, it&#8217;s really just up to you and your team&#8217;s comfort level on OSS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maxime S&#233;guin</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2363</link>
		<dc:creator>Maxime S&#233;guin</dc:creator>
		<pubDate>Sun, 02 May 2010 16:15:23 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2363</guid>
		<description>Thank you for this nice article!

Speaking of FubuMVC, would you suggest it over ASP.NET MVC if a project has &lt;em&gt;carte blanche&lt;/em&gt; and why? I know it is more flexible right now but don&#039;t you think that, in the end, a side project like FubuMVC would get less functionalities knowing the different resources (team size, money...)

Maxime</description>
		<content:encoded><![CDATA[<p>Thank you for this nice article!</p>
<p>Speaking of FubuMVC, would you suggest it over ASP.NET MVC if a project has <em>carte blanche</em> and why? I know it is more flexible right now but don&#8217;t you think that, in the end, a side project like FubuMVC would get less functionalities knowing the different resources (team size, money&#8230;)</p>
<p>Maxime</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jesus garza</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2362</link>
		<dc:creator>jesus garza</dc:creator>
		<pubDate>Sun, 02 May 2010 02:13:41 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2362</guid>
		<description>Hey Jimmy,

Sorry if this is too newbie, but where do you get _nestedContainerKey from?

Thanks.</description>
		<content:encoded><![CDATA[<p>Hey Jimmy,</p>
<p>Sorry if this is too newbie, but where do you get _nestedContainerKey from?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luca Milan</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2361</link>
		<dc:creator>Luca Milan</dc:creator>
		<pubDate>Thu, 29 Apr 2010 21:28:57 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2361</guid>
		<description>Thx Jimmy. 

I could use this approach within a HTTP module (FubuMVC is much better!) between the beginning and end of the web request, so I guarantee the atomicity of the request. </description>
		<content:encoded><![CDATA[<p>Thx Jimmy. </p>
<p>I could use this approach within a HTTP module (FubuMVC is much better!) between the beginning and end of the web request, so I guarantee the atomicity of the request. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mbratton</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2360</link>
		<dc:creator>mbratton</dc:creator>
		<pubDate>Thu, 29 Apr 2010 21:23:21 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2360</guid>
		<description>Seems pretty involved. This is one of the driving reasons I created Siege.ServiceLocation ... it contextually figures out which dependencies to inject an infinite level deep and you don&#039;t have to track any of this stuff.

If a dependency 5 levels deep is contextual and the rest are not, it resolves all with the default and the contextual dependency is correctly resolved. No need for code like this ...

Not intending to hijack, just pointing out a different approach.</description>
		<content:encoded><![CDATA[<p>Seems pretty involved. This is one of the driving reasons I created Siege.ServiceLocation &#8230; it contextually figures out which dependencies to inject an infinite level deep and you don&#8217;t have to track any of this stuff.</p>
<p>If a dependency 5 levels deep is contextual and the rest are not, it resolves all with the default and the contextual dependency is correctly resolved. No need for code like this &#8230;</p>
<p>Not intending to hijack, just pointing out a different approach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2359</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Thu, 29 Apr 2010 12:39:18 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2359</guid>
		<description>@Luca

Yep, you sure can.  The only other issue is that many, many other services used by MVC are still all service-located or hard-coded, so your job becomes more difficult vs. other frameworks (like FubuMVC).</description>
		<content:encoded><![CDATA[<p>@Luca</p>
<p>Yep, you sure can.  The only other issue is that many, many other services used by MVC are still all service-located or hard-coded, so your job becomes more difficult vs. other frameworks (like FubuMVC).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luca Milan</title>
		<link>http://lostechies.com/jimmybogard/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection/#comment-2358</link>
		<dc:creator>Luca Milan</dc:creator>
		<pubDate>Thu, 29 Apr 2010 06:12:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/28/dependency-injection-in-asp-net-mvc-contextual-controller-injection.aspx#comment-2358</guid>
		<description>Hi Jimmy, 

you can use this pattern for inject a UnitOfWork into controller and our related services?  

thx!</description>
		<content:encoded><![CDATA[<p>Hi Jimmy, </p>
<p>you can use this pattern for inject a UnitOfWork into controller and our related services?  </p>
<p>thx!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
