<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET MVC</title><link>http://forums.asp.net/1146.aspx</link><description>Discussions regarding Model-View-Controller (MVC) support in ASP.NET.  &lt;a href="http://forums.asp.net/1215.aspx"&gt;T4MVC subforum&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2150111.aspx</link><pubDate>Sun, 03 Feb 2008 06:53:53 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2150111</guid><dc:creator>sliderhouserules</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2150111.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2150111</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;AbstractApproach:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; 
&lt;ol&gt;
&lt;li&gt;CTP (the release stage of MVC right now) stands for &lt;b&gt;Community&lt;/b&gt; technical preview. Community, I think, means the community of developers. These releases are meant for developers to play with and get to use and break, with the intent of using, but not necessarily for production purposes. I have no problem developing client&amp;#39;s site with CTP products, but I do so with the understanding that the expected ship date of the completed version is before the expected ship date of my site, so that I can get the full version before going public. CTP versions are wonderful things, and they often work very well (some better than others). But by their nature, you cannot assume that Microsoft has done all its homework and created a truly complete and ready to roll framework. The security setup I mentioned probably works, and it is probably very secure, but you can&amp;#39;t be absolutely sure yet, and at enterprise level, that&amp;#39;s not good enough.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;Was this directed at me? If so, you missed the part where I said I know this is the first drop of a CTP. You also missed where I said this first drop of this CTP correlates perfectly with the overall trend of MS&amp;#39;s stuff which my complaint is actually directed at. You also missed the part where I expressed my hopes that this one will be different.&lt;/li&gt;&lt;/ol&gt;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2149462.aspx</link><pubDate>Sat, 02 Feb 2008 15:08:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2149462</guid><dc:creator>AbstractApproach</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2149462.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2149462</wfw:commentRss><description>&lt;p&gt;Two points.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;CTP (the release stage of MVC right now) stands for &lt;b&gt;Community&lt;/b&gt; technical preview. Community, I think, means the community of developers. These releases are meant for developers to play with and get to use and break, with the intent of using, but not necessarily for production purposes. I have no problem developing client&amp;#39;s site with CTP products, but I do so with the understanding that the expected ship date of the completed version is before the expected ship date of my site, so that I can get the full version before going public. CTP versions are wonderful things, and they often work very well (some better than others). But by their nature, you cannot assume that Microsoft has done all its homework and created a truly complete and ready to roll framework. The security setup I mentioned probably works, and it is probably very secure, but you can&amp;#39;t be absolutely sure yet, and at enterprise level, that&amp;#39;s not good enough.&lt;/li&gt;&lt;li&gt;If you can override MvcRouteHandler, why couldn&amp;#39;t we make a new MvcRouteHandler that takes authentication into consideration?&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public class&lt;/span&gt; SecureMvcRouteHandler : MvcRouteHandler
{
    &lt;span class="kwd"&gt;protected override&lt;/span&gt; IHttpHandler GetHttpHandler( RequestContext requestContext )
    {
        &lt;span class="kwd"&gt;if&lt;/span&gt; ( !requestContext.HttpContext.User.Identity.IsAuthenticated )
        {
            &lt;span class="kwd"&gt;throw new&lt;/span&gt; System.Security.Authentication.AuthenticationException( &lt;span class="st"&gt;&amp;quot;Not authenticated&amp;quot;&lt;/span&gt; );
        }
        &lt;span class="kwd"&gt;return base&lt;/span&gt;.GetHttpHandler( requestContext );
    }
}&lt;/pre&gt;&amp;nbsp;&lt;br /&gt;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2148402.aspx</link><pubDate>Fri, 01 Feb 2008 19:07:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2148402</guid><dc:creator>sliderhouserules</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2148402.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2148402</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;dimi3:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/p&gt;&lt;p&gt;Thanks to all of you.&lt;br /&gt;As my application is &amp;quot;pretty&amp;quot; simple,&amp;nbsp; I decided to have an &lt;b&gt;Admin&lt;/b&gt; &lt;i&gt;Project&lt;/i&gt; in my existing &lt;i&gt;Solution&lt;/i&gt;,&lt;br /&gt;with the following route:&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;b id="1"&gt;1    &lt;/b&gt;RouteTable.Routes.Add(&lt;span class="kwd"&gt;new&lt;/span&gt; Route&lt;br /&gt;&lt;b id="2"&gt;2    &lt;/b&gt;{&lt;br /&gt;&lt;b id="3"&gt;3    &lt;/b&gt;    Url = &lt;span class="st"&gt;&amp;quot;Admin/[controller]/[action]/[id]&amp;quot;&lt;/span&gt;,&lt;br /&gt;&lt;b id="4"&gt;4    &lt;/b&gt;    Defaults = &lt;span class="kwd"&gt;new&lt;/span&gt; { action = &lt;span class="st"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;, id = (&lt;span class="kwd"&gt;string&lt;/span&gt;)&lt;span class="kwd"&gt;null&lt;/span&gt; },&lt;br /&gt;&lt;b id="5"&gt;5    &lt;/b&gt;    RouteHandler = &lt;span class="kwd"&gt;typeof&lt;/span&gt;(MvcRouteHandler)&lt;br /&gt;&lt;b id="6"&gt;6    &lt;/b&gt;});&lt;/div&gt;&lt;/BLOCKQUOTE&gt; This is what I looked at doing at first, but I want to allow modules to be added or excluded easily, and all pages/controllers are fully qualified with their module as part of their path (for views) or namespace (for controllers) so I thought it was a better idea to make it default supported functionality.&lt;/pre&gt;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2147327.aspx</link><pubDate>Fri, 01 Feb 2008 09:54:44 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2147327</guid><dc:creator>Fredrik N</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2147327.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2147327</wfw:commentRss><description>&lt;p&gt;dimi3:&lt;/p&gt;
&lt;p&gt;Great! That is better, at least how I should have done it. Seperate the Admin from the public app.. &lt;/p&gt;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2147245.aspx</link><pubDate>Fri, 01 Feb 2008 08:54:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2147245</guid><dc:creator>dimi3</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2147245.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2147245</wfw:commentRss><description>&lt;p&gt;Thanks to all of you.&lt;br /&gt;As my application is &amp;quot;pretty&amp;quot; simple,&amp;nbsp; I decided to have an &lt;b&gt;Admin&lt;/b&gt; &lt;i&gt;Project&lt;/i&gt; in my existing &lt;i&gt;Solution&lt;/i&gt;,&lt;br /&gt;with the following route:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;b id="1"&gt;1    &lt;/b&gt;RouteTable.Routes.Add(&lt;span class="kwd"&gt;new&lt;/span&gt; Route
&lt;b id="2"&gt;2    &lt;/b&gt;{
&lt;b id="3"&gt;3    &lt;/b&gt;    Url = &lt;span class="st"&gt;&amp;quot;Admin/[controller]/[action]/[id]&amp;quot;&lt;/span&gt;,
&lt;b id="4"&gt;4    &lt;/b&gt;    Defaults = &lt;span class="kwd"&gt;new&lt;/span&gt; { action = &lt;span class="st"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;, id = (&lt;span class="kwd"&gt;string&lt;/span&gt;)&lt;span class="kwd"&gt;null&lt;/span&gt; },
&lt;b id="5"&gt;5    &lt;/b&gt;    RouteHandler = &lt;span class="kwd"&gt;typeof&lt;/span&gt;(MvcRouteHandler)
&lt;b id="6"&gt;6    &lt;/b&gt;});
&lt;/pre&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2146632.aspx</link><pubDate>Fri, 01 Feb 2008 01:13:51 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2146632</guid><dc:creator>sliderhouserules</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2146632.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2146632</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;That didn&amp;#39;t tie together very well, so here&amp;#39;s an example of a controller registration for Spring.Net.&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="cmt"&gt;&amp;lt;!-- Controllers --&amp;gt;&lt;/span&gt;
&amp;lt;&lt;span class="tag"&gt;object&lt;/span&gt;&lt;span class="attr"&gt; id=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Shell.Home&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; type=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Shell.Controllers.HomeController, Shell.Controllers&amp;quot;&lt;/span&gt; /&amp;gt;
&lt;/pre&gt;&amp;nbsp;&lt;br /&gt;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2146625.aspx</link><pubDate>Fri, 01 Feb 2008 01:09:24 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2146625</guid><dc:creator>sliderhouserules</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2146625.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2146625</wfw:commentRss><description>&lt;p&gt;I forgot to mention that my solution is fully partitioned into modules (small sampling):&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;Solution&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font face="courier new,courier"&gt;Admin\&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Admin.Views&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Admin.Controllers&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Admin.Interfaces&lt;br /&gt;&amp;nbsp; Shell\&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shell.Views&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shell.Controllers&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shell.Interfaces&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shell.WebRoot&lt;/font&gt;&lt;/p&gt;&lt;p&gt;The WebRoot project is where Global.asax lives, and I use MSBuild tasks to copy all files (content and build output) from the module projects into their appropriate place in the WebRoot (dll&amp;#39;s into bin\, etc.) since I&amp;#39;m using dependency injection and so don&amp;#39;t have any project references (except for the Interfaces projects).&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2146622.aspx</link><pubDate>Fri, 01 Feb 2008 01:02:20 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2146622</guid><dc:creator>sliderhouserules</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2146622.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2146622</wfw:commentRss><description>&lt;p&gt;And these routes are now fully supported.&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;RouteTable.Routes.Add(&lt;span class="kwd"&gt;new&lt;/span&gt; Route
{
  Url = &lt;span class="st"&gt;&amp;quot;[module]/[controller].mvc/[action]/[id]&amp;quot;&lt;/span&gt;,
  Defaults = &lt;span class="kwd"&gt;new&lt;/span&gt; { action = &lt;span class="st"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;, id = (&lt;span class="kwd"&gt;string&lt;/span&gt;)&lt;span class="kwd"&gt;null&lt;/span&gt; },
  RouteHandler = &lt;span class="kwd"&gt;typeof&lt;/span&gt;(ModuleMvcRouteHandler)
});

RouteTable.Routes.Add(&lt;span class="kwd"&gt;new&lt;/span&gt; Route
{
  Url = &lt;span class="st"&gt;&amp;quot;Default.aspx&amp;quot;&lt;/span&gt;,
  Defaults = &lt;span class="kwd"&gt;new&lt;/span&gt; { module = &lt;span class="st"&gt;&amp;quot;Shell&amp;quot;&lt;/span&gt;, controller = &lt;span class="st"&gt;&amp;quot;Home&amp;quot;&lt;/span&gt;, action = &lt;span class="st"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;, id = (&lt;span class="kwd"&gt;string&lt;/span&gt;)&lt;span class="kwd"&gt;null&lt;/span&gt; },
  RouteHandler = &lt;span class="kwd"&gt;typeof&lt;/span&gt;(ModuleMvcRouteHandler)
});&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2146611.aspx</link><pubDate>Fri, 01 Feb 2008 00:55:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2146611</guid><dc:creator>sliderhouserules</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2146611.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2146611</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;AbstractApproach:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;...for a real simple web app with fairly insensitive data it will probably work.&lt;/div&gt;&lt;/BLOCKQUOTE&gt; This is, IMNSHO, one of the main problems with a lot of the stuff that MS puts out, and this first version of MVC is no different. I realize this question was more than likely asked from this very perspective (a simple site) but the question is perfectly in line with a major shortcoming of this framework (and others) when you contrast it against the stuff that P&amp;amp;P recommends for enterprise development. MS has stated that SMB developers are their main clientèle, but I would then counter with why is that? I work in an IT department (one of many here) for a large Fortune 500 company, and due to the corporate mentality that we all love so much, I work with mostly junior developers trying to create and maintain large enterprise systems. I am, in effect, trying to train myself to be an architect, because there&amp;#39;s just nobody else doing it. I would submit that there is a rather large, unaccounted for, portion of MS&amp;#39;s clientèle  that are just like me: enterprise developers working on large systems with very little or no architectural oversight or guidance. And we turn to the community at large, and MS in particular, to find some of that guidance. And yet, we find that MS is at odds with itself in some ways. Or putting out stuff that just isn&amp;#39;t aimed at us. It can be very frustrating. I know this is just the first drop of MVC, so I&amp;#39;m hoping the &amp;quot;if you&amp;#39;re doing enterprise development you&amp;#39;ll want to use MVC&amp;quot; statement holds true in the end.&lt;/p&gt;&lt;p&gt;Anyway, now that that&amp;#39;s out there... the main point I&amp;#39;m driving at is P&amp;amp;P&amp;#39;s guidance concerning composite applications. &amp;quot;Simple&amp;quot; apps will maybe need one little separate admin section, but what about a framework for a large enterprise system that needs many different modules, the ability to plug and unplug modules depending on the customized LOB application built from the framework? Duplicate controllers named Home, indeed!&lt;/p&gt;&lt;p&gt;Here&amp;#39;s what I&amp;#39;ve done to enable module (or area) separation and routing, maybe it will be of value to you in your simple(r) application or to others trying to build a more complex system. I unfortunately had to start from the top, since the routing engine doesn&amp;#39;t handle this stuff in any way that I could figure out. So I wrote my own. I&amp;#39;m using Spring.Net for dependency injection, so you can make direct instantiations of the appropriate classes instead to eliminate that complexity if you aren&amp;#39;t into DI. I&amp;#39;ve omitted some details (methods, properties) for brevity (and this is still a lot of code! Sorry). &lt;br /&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public class&lt;/span&gt; ModuleMvcRouteHandler : MvcRouteHandler&lt;br /&gt;{&lt;br /&gt;  &lt;span class="kwd"&gt;protected override&lt;/span&gt; IHttpHandler GetHttpHandler(RequestContext requestContext)&lt;br /&gt;  {&lt;br /&gt;    ModuleMvcHandler handler = &lt;span class="kwd"&gt;new&lt;/span&gt; ModuleMvcHandler();&lt;br /&gt;    handler.RequestContext = requestContext;&lt;br /&gt;    &lt;span class="kwd"&gt;return&lt;/span&gt; handler;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwd"&gt;class&lt;/span&gt; ModuleMvcHandler : IHttpHandler, IRequiresSessionState&lt;br /&gt;{&lt;br /&gt;  &lt;span class="kwd"&gt;void&lt;/span&gt; IHttpHandler.ProcessRequest(HttpContext httpContext)&lt;br /&gt;  {&lt;br /&gt;    &lt;span class="kwd"&gt;this&lt;/span&gt;.ProcessRequest(httpContext);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;span class="cmt"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;  /// Handles the http request &lt;br /&gt;  /// &amp;lt;/summary&amp;gt;&lt;br /&gt;  /// &amp;lt;param name=&amp;quot;httpContext&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
  &lt;span class="kwd"&gt;protected virtual void&lt;/span&gt; ProcessRequest(HttpContext httpContext)&lt;br /&gt;  {&lt;br /&gt;    &lt;span class="kwd"&gt;if&lt;/span&gt; (&lt;span class="kwd"&gt;this&lt;/span&gt;.RequestContext == &lt;span class="kwd"&gt;null&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;      &lt;span class="kwd"&gt;throw new&lt;/span&gt; InvalidOperationException(&lt;span class="st"&gt;&amp;quot;The MvcHandler requires that a valid RequestContext be set.&amp;quot;&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwd"&gt;string&lt;/span&gt; routeModule = GetRequiredString(&lt;span class="kwd"&gt;this&lt;/span&gt;.RequestContext.RouteData, &lt;span class="st"&gt;&amp;quot;module&amp;quot;&lt;/span&gt;);&lt;br /&gt;    &lt;span class="kwd"&gt;string&lt;/span&gt; routeController = GetRequiredString(&lt;span class="kwd"&gt;this&lt;/span&gt;.RequestContext.RouteData, &lt;span class="st"&gt;&amp;quot;controller&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    IController controllerInstance = &lt;span class="kwd"&gt;this&lt;/span&gt;.GetControllerInstance(routeModule + &lt;span class="st"&gt;&amp;quot;.&amp;quot;&lt;/span&gt; + routeController);&lt;br /&gt;    &lt;span class="kwd"&gt;if&lt;/span&gt; (controllerInstance == &lt;span class="kwd"&gt;null&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;      &lt;span class="kwd"&gt;throw new&lt;/span&gt; InvalidOperationException(&lt;span class="kwd"&gt;string&lt;/span&gt;.Format(&lt;span class="st"&gt;&amp;quot;The controller for path &amp;#39;{0}&amp;#39; could not be found or it does not implement the IController interface.&amp;quot;&lt;/span&gt;,&lt;br /&gt;        &lt;span class="kwd"&gt;new object&lt;/span&gt;[] { &lt;span class="kwd"&gt;this&lt;/span&gt;.RequestContext.HttpContext.Request.Path }));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    ControllerContext controllerContext = &lt;span class="kwd"&gt;new&lt;/span&gt; ControllerContext(&lt;span class="kwd"&gt;this&lt;/span&gt;.RequestContext, controllerInstance);&lt;br /&gt;    controllerInstance.Execute(controllerContext);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;span class="cmt"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;  /// Creates an instance of the requested controller using the configured IModuleControllerFactory&lt;br /&gt;  /// &amp;lt;/summary&amp;gt;&lt;br /&gt;  /// &amp;lt;param name=&amp;quot;controllerName&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;  /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
  &lt;span class="kwd"&gt;protected virtual&lt;/span&gt; IController GetControllerInstance(&lt;span class="kwd"&gt;string&lt;/span&gt; controllerName)&lt;br /&gt;  {&lt;br /&gt;    &lt;span class="cmt"&gt;// instantiate the controller factory&lt;/span&gt;
    IApplicationContext context = ContextRegistry.GetContext();
    IModuleControllerFactory controllerFactory = (IModuleControllerFactory)context.GetObject(&lt;span class="st"&gt;&amp;quot;IModuleControllerFactory&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    &lt;span class="cmt"&gt;// have the factory build the controller&lt;/span&gt;
    &lt;span class="kwd"&gt;return&lt;/span&gt; controllerFactory.CreateController(&lt;span class="kwd"&gt;this&lt;/span&gt;.RequestContext, controllerName);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwd"&gt;class&lt;/span&gt; ModuleControllerFactory : IModuleControllerFactory {&lt;br /&gt;  IController IModuleControllerFactory.CreateController(RequestContext context, &lt;span class="kwd"&gt;string&lt;/span&gt; controllerName) {&lt;br /&gt;    &lt;span class="kwd"&gt;return this&lt;/span&gt;.CreateController(context, controllerName);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;span class="kwd"&gt;public virtual&lt;/span&gt; IController CreateController(RequestContext context, &lt;span class="kwd"&gt;string&lt;/span&gt; controllerName) {&lt;br /&gt;    IApplicationContext objectFactory = ContextRegistry.GetContext();&lt;br /&gt;    IController controller = (IController)objectFactory.GetObject(controllerName, &lt;span class="kwd"&gt;typeof&lt;/span&gt;(IController));&lt;br /&gt;    controller = &lt;span class="kwd"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwd"&gt;if&lt;/span&gt; (controller != &lt;span class="kwd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; &lt;span class="kwd"&gt;typeof&lt;/span&gt;(Controller).IsAssignableFrom(controller.GetType())) {&lt;br /&gt;      &lt;span class="cmt"&gt;// can&amp;#39;t do this yet, ViewPage.ViewData is Internal :(&lt;br /&gt;      // have to fully qualify view paths in RenderView until can implement custom ViewFactory&lt;br /&gt;      //IViewFactory viewFactory = (IViewFactory)objectFactory.GetObject(&amp;quot;IModuleViewFactory&amp;quot;, typeof(IViewFactory));&lt;/span&gt;
    }

    &lt;span class="kwd"&gt;return&lt;/span&gt; controller;&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2146028.aspx</link><pubDate>Thu, 31 Jan 2008 19:02:22 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2146028</guid><dc:creator>AbstractApproach</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2146028.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2146028</wfw:commentRss><description>&lt;p&gt;I agree with Fredrik N, I would locate your admin in another project in your solution, running as a separate website on your server (this is what I usually do. It also means I can shut that site off).&lt;/p&gt;
&lt;p&gt;But, in the name of completeness and maybe simplicity, there is a way to do it as a sub folder.&lt;/p&gt;
&lt;p&gt;In /Views/Admin/ add Web.Config with the following data:&lt;/p&gt;
&lt;pre class="coloredcode"&gt;&amp;lt;&lt;span class="tag"&gt;system.web&lt;/span&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;span class="tag"&gt;authentication&lt;/span&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;span class="tag"&gt;allow&lt;/span&gt;&lt;span class="attr"&gt; users=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;*&amp;quot;&lt;/span&gt; /&amp;gt;&lt;br /&gt;    &amp;lt;&lt;span class="tag"&gt;deny&lt;/span&gt;&lt;span class="attr"&gt; users=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;?&amp;quot;&lt;/span&gt; /&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;span class="tag"&gt;authentication&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;span class="tag"&gt;system.web&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;p&gt;Now your files cannot be requested from the web. But your controllers can still render them, so you can now create an admin controller. In the admin controller you can override OnPreAction to perform a security check and throw a security exception if you are not authorized, thereby stopping your response, and allowing you to catch the exception and render an error page instead.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not absolutely certain about the security of this method, there may be a hole in it somewhere (and that somewhere is almost certainly either your controller or the controller base class, as the web.config will do what it is supposed to...it is from the WebForms side of things, and is known to work). I would not trust this for a US military site, but for a real simple web app with fairly insensitive data it will probably work.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2145683.aspx</link><pubDate>Thu, 31 Jan 2008 16:57:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2145683</guid><dc:creator>Fredrik N</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2145683.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2145683</wfw:commentRss><description>&lt;p&gt;Sorry, the web.config will not work in the Admin folder because the files aren&amp;#39;t requested. So in your case I should have seperated the Admin secion as an own application and use Controllers and View in the admin, maybe there is a solution now, but I should probably never put an Admin folder as a sub to a public site.. but that is me ;)&lt;/p&gt;</description></item><item><title>Re: Admin Part (place)</title><link>http://forums.asp.net/thread/2145664.aspx</link><pubDate>Thu, 31 Jan 2008 16:49:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2145664</guid><dc:creator>Fredrik N</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2145664.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2145664</wfw:commentRss><description>&lt;p&gt;When I create web apps, I always seperate admin from public sites because of security reasons. But that is for enterprise applications. You can if you want use a Admin folder, but the &amp;lt;location&amp;gt; element will not work with the Rout handler in this drop what I know, but you can put a web.config in the Admin folder to demand a login.&lt;/p&gt;</description></item><item><title>Admin Part (place)</title><link>http://forums.asp.net/thread/2145598.aspx</link><pubDate>Thu, 31 Jan 2008 16:33:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2145598</guid><dc:creator>dimi3</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2145598.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2145598</wfw:commentRss><description>&lt;p&gt;My website needs an Admin part. Where should I put it?&lt;/p&gt;&lt;p&gt;- Create an &lt;b&gt;Admin&lt;/b&gt; folder in &lt;b&gt;Controllers &lt;/b&gt;and &lt;b&gt;Views&lt;/b&gt;?&lt;br /&gt;- No &lt;b&gt;Admin&lt;/b&gt; folders at all?&lt;br /&gt;- In another Solution?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;What about the routes?&lt;/p&gt;&lt;p&gt;Do you have any suggestions?&lt;/p&gt;&lt;p&gt;Thanks!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>