Virtual Directoryhttp://forums.asp.net/t/1629131.aspx/1?Virtual+DirectoryMon, 06 Dec 2010 07:25:33 -050016291314193507http://forums.asp.net/p/1629131/4193507.aspx/1?Virtual+DirectoryVirtual Directory <p>Hello,</p> <p>been playing around a bit more with the MVC Framework, and succeeded in running our standard ASP.NET application together with an MVC application. As long as I run the application through the integrated IIS from Visual Studio it all works fine, but now I'm trying to run it from a Virtual Directory under ISS.</p> <p>The URL now looks like this : http://localhost/&lt;directory&gt;/</p> <p>The normal ASP.NET pages etc all work fine, but when I try to call an URL that should be mapped to a controller from MVC it all goes haywire. To give an example:</p> <p>just going to http://localhost/&lt;directory&gt; opens the index.aspx page and all links etc work fine. If I enter http://localhost/&lt;directory&gt;/Force I expect the index page of the Force controller to be triggered, but instead I'm receiving an 404 error page. So apparently I can't get to the controller.</p> <p>I've gone to the properties page of the web application and used the &quot;Create Virtual Directory&quot; there. I tried playing with the Routine table to add expressions to catch the subfolder in the URL, but doesn't seem to be working.</p> <p>Anyone can explain what I need to be doing to get the MVC calls through? I should tell you that there's an IHttpModule doing UrlRewrites, but it doesn't seem to cause a problem when working without the directory in the URL.</p> 2010-12-02T09:14:06-05:004193584http://forums.asp.net/p/1629131/4193584.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>IIS will understand the request for .aspx and hence pass the request to asp.net engine.</p> <p>In mvc, the URL is extension less so IIS don't understand that to whome it need to pass the request.</p> <p>There is a ISAPI Rewrite (<a href="http://iirf.codeplex.com/">http://iirf.codeplex.com/</a>) register this in your IIS.</p> <p>All the MVC pages and links will definately work</p> <p><br> </p> 2010-12-02T09:54:17-05:004193588http://forums.asp.net/p/1629131/4193588.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>I'm currently using IIS7, isn' tthis build in ?</p> 2010-12-02T09:58:26-05:004193723http://forums.asp.net/p/1629131/4193723.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>The above mentioned project is not an option for us, we're running Windows Server 2008 64bit systems, thus the DLL is not supported.</p> 2010-12-02T11:26:24-05:004193784http://forums.asp.net/p/1629131/4193784.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>MVC support is definitely built in IIS 7. (I may be wrong here) Does your global.asax have all routes registered?<br> </p> 2010-12-02T12:04:28-05:004193799http://forums.asp.net/p/1629131/4193799.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>Yes,</p> <p>The routers have been registered. It's just one route for now. When I call it in the browser I get the 404 page:</p> &lt;div id=&quot;header&quot;&gt; <h1>Server Error in Application &quot;TEENFORCE/ARNE&quot;</h1> &lt;/div&gt; &lt;div id=&quot;server_version&quot;&gt; <p>Internet Information Services 7.0</p> &lt;/div&gt; &lt;div id=&quot;content&quot;&gt; &lt;div&gt; <fieldset><legend>Error Summary</legend> <h2>HTTP Error 404.0 - Not Found</h2> <h3>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h3> </fieldset> &lt;/div&gt; &lt;div&gt; <fieldset><legend>Detailed Error Information</legend>&lt;div id=&quot;details-left&quot;&gt; <table border="0" cellpadding="0" cellspacing="0" class="mceItemTable"> <tbody> <tr> <th>Module</th> <td>IIS Web Core</td> </tr> <tr> <th>Notification</th> <td>MapRequestHandler</td> </tr> <tr> <th>Handler</th> <td>StaticFile</td> </tr> <tr> <th>Error Code</th> <td>0x80070002</td> </tr> </tbody> </table> &lt;/div&gt; &lt;div id=&quot;details-right&quot;&gt; <table border="0" cellpadding="0" cellspacing="0" class="mceItemTable"> <tbody> <tr> <th>Requested URL</th> <td>http://localhost:80/Arne/api/TenForce</td> </tr> <tr> <th>Physical Path</th> <td>C:\Users\arne.de.herdt\Documents\Trunk\Robinson\RobinsonWebApp\api\TenForce</td> </tr> <tr> <th>Logon Method</th> <td>Anonymous</td> </tr> <tr> <th>Logon User</th> <td>Anonymous</td> </tr> </tbody> </table> &lt;div&gt;&lt;/div&gt; &lt;/div&gt; </fieldset> &lt;/div&gt; &lt;div&gt; <fieldset><legend>Most likely causes:</legend> <ul> <li>The directory or file specified does not exist on the Web server. </li><li>The URL contains a typographical error. </li><li>A custom filter or module, such as URLScan, restricts access to the file. </li></ul> </fieldset> &lt;/div&gt; &lt;div&gt; <fieldset><legend>Things you can try:</legend> <ul> <li>Create the content on the Web server. </li><li>Review the browser URL. </li><li>Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. &nbsp;</li></ul> </fieldset>&lt;/div&gt; <p>The routine file looks like this:</p> <p><br> </p> <pre class="prettyprint">/// &lt;summary&gt; /// This function registers all the routers for the MVC application. /// &lt;/summary&gt; /// &lt;param name=&quot;routes&quot;&gt;The collection of routes to be registered.&lt;/param&gt; protected static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(&quot;{resource}.axd/{*pathInfo}&quot;); // Test route for the TenForce controller. routes.MapRoute( &quot;TenForce&quot;, &quot;api/TenForce&quot;, new { controller = &quot;TenForce&quot;, action = &quot;Index&quot;} ); }</pre><br> <br> <p><br> </p> &lt;div&gt;&lt;/div&gt; &lt;/div&gt; 2010-12-02T12:09:17-05:004193810http://forums.asp.net/p/1629131/4193810.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>did you deploy also mvc dll?( are you using 1 or 2)?<br> </p> 2010-12-02T12:13:30-05:004193817http://forums.asp.net/p/1629131/4193817.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>using MVC 2, and I've marked the DLL to be copied on build.</p> 2010-12-02T12:17:29-05:004193826http://forums.asp.net/p/1629131/4193826.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>I advise checking the routing with <a href="http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx"> http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx</a> since it is very restrictive and possibly something is happening with the URL that is not expected.<br> </p> 2010-12-02T12:21:46-05:004193832http://forums.asp.net/p/1629131/4193832.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>did it, resulted in 404 as well...as you mentioned on MSN, the routing isn't loaded at all.</p> 2010-12-02T12:24:43-05:004193858http://forums.asp.net/p/1629131/4193858.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>I removed the IHttpModule from the equation for now, but this results in the a standard : the page cannot be displayed....</p> 2010-12-02T12:38:59-05:004193901http://forums.asp.net/p/1629131/4193901.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Arne De Herdt</h4> I removed the IHttpModule from the equation for now, but this results in the a standard : the page cannot be displayed....</blockquote> <p></p> <p>please make another 2 test: </p> <p>1.if you put a &quot;hellpo world&quot; asp.net application , does it work? </p> <p>2.if you put a &quot;hellpo world&quot; asp.net MVC application , does it work?</p> 2010-12-02T13:09:57-05:004193910http://forums.asp.net/p/1629131/4193910.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>both work just fine.</p> <p>So the problem is something related then to our IHttpModule that's performing rewrites.</p> 2010-12-02T13:16:03-05:004194072http://forums.asp.net/p/1629131/4194072.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>I've tried everything in the book and what google could find:</p> <p><br> </p> <p>- add the references for MVC</p> <p>- remove all custom modules</p> <p>- Add the Controller &amp; View Structure</p> <p>- Add the required entries in the web.config file</p> <p>- Cross check all handlers and modules against a working MVC application</p> <p><br> </p> <p>As long as the classic ASP.NET webpage is doing it's stuff it's all peachy, but as soon as I need to step onto the MVC then it all goes haywire.</p> <p>Standalone MVC applications work like a charm on the current server config as do ASP.NET applications, but when I try to place some MVC stuff into our web application, all hell breaks loose....</p> 2010-12-02T15:21:35-05:004194139http://forums.asp.net/p/1629131/4194139.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>Which version of VS.NET and MVC are you using.</p> <p>If using VS.NET 2008, check your web.config whether it has this entry?</p> <p><pre class="prettyprint">&lt;httpModules&gt; &lt;add name=&quot;UrlRoutingModule&quot; type=&quot;System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;/&gt; &lt;/httpModules&gt;</pre><br> <br> </p> <p>The UrlRoutingModule evaluates a request and checks if it matches a route that is stored in the RouteTable. If the route matches, it overrides the default handler (IHttpHandler) for the request so that the MVC framework handles the request.</p> <p>From <a target="_blank" title="http://www.manning.com/palermo/" href="http://www.manning.com/palermo/"> ASP.NET MVC in Action</a> book.<br> </p> 2010-12-02T16:12:37-05:004194254http://forums.asp.net/p/1629131/4194254.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>Could you try setting it up as an IIS application, not a virtual directory?&nbsp;</p> 2010-12-02T17:34:04-05:004194433http://forums.asp.net/p/1629131/4194433.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>That module is present and loaded. Discovered it was missing when crosschecking the modules between our application and the MVC applications.</p> <p>As for running the site as a standalone application, that's not a viable option due the deployment configuration, but I will check tommorow if it can be done regardless.</p> 2010-12-02T20:02:07-05:004195099http://forums.asp.net/p/1629131/4195099.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>I tried setting up a Application for the website, but when I navigate to it, all I get is some sort of binary output....</p> 2010-12-03T07:39:05-05:004195198http://forums.asp.net/p/1629131/4195198.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>is it possible the RewriteUrl in our custom HttpModule is breaking the MVC?</p> 2010-12-03T08:48:52-05:004195685http://forums.asp.net/p/1629131/4195685.aspx/1?Re+Virtual+DirectoryRe: Virtual Directory <p>Finnaly after long searching and tinkering I managed to get everything working.</p> <p>The MvcHttphandler never got invoked due crappy configuration on IIS...</p> 2010-12-03T14:19:05-05:00