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.
The URL now looks like this : http://localhost/<directory>/
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:
just going to http://localhost/<directory> opens the index.aspx page and all links etc work fine. If I enter http://localhost/<directory>/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.
I've gone to the properties page of the web application and used the "Create Virtual Directory" 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.
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.
/// <summary>
/// This function registers all the routers for the MVC application.
/// </summary>
/// <param name="routes">The collection of routes to be registered.</param>
protected static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Test route for the TenForce controller.
routes.MapRoute(
"TenForce",
"api/TenForce",
new { controller = "TenForce", action = "Index"}
);
}
Arne De Herd...
Member
1 Points
29 Posts
Virtual Directory
Dec 02, 2010 09:14 AM|LINK
Hello,
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.
The URL now looks like this : http://localhost/<directory>/
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:
just going to http://localhost/<directory> opens the index.aspx page and all links etc work fine. If I enter http://localhost/<directory>/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.
I've gone to the properties page of the web application and used the "Create Virtual Directory" 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.
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.
r.rajeshkhun...
Participant
1358 Points
250 Posts
Re: Virtual Directory
Dec 02, 2010 09:54 AM|LINK
IIS will understand the request for .aspx and hence pass the request to asp.net engine.
In mvc, the URL is extension less so IIS don't understand that to whome it need to pass the request.
There is a ISAPI Rewrite (http://iirf.codeplex.com/) register this in your IIS.
All the MVC pages and links will definately work
======================================
Microsoft® Community Contributor 2011 | AWARD
MCTS
My Blog
Follow Me
Arne De Herd...
Member
1 Points
29 Posts
Re: Virtual Directory
Dec 02, 2010 09:58 AM|LINK
I'm currently using IIS7, isn' tthis build in ?
Arne De Herd...
Member
1 Points
29 Posts
Re: Virtual Directory
Dec 02, 2010 11:26 AM|LINK
The above mentioned project is not an option for us, we're running Windows Server 2008 64bit systems, thus the DLL is not supported.
sachingusain
Star
8786 Points
1702 Posts
Re: Virtual Directory
Dec 02, 2010 12:04 PM|LINK
MVC support is definitely built in IIS 7. (I may be wrong here) Does your global.asax have all routes registered?
Thanks.
Arne De Herd...
Member
1 Points
29 Posts
Re: Virtual Directory
Dec 02, 2010 12:09 PM|LINK
Yes,
The routers have been registered. It's just one route for now. When I call it in the browser I get the 404 page:
<div id="header">Server Error in Application "TEENFORCE/ARNE"
</div> <div id="server_version">Internet Information Services 7.0
</div> <div id="content"> <div> </div> <div> </div> <div> </div> <div> </div>The routine file looks like this:
/// <summary> /// This function registers all the routers for the MVC application. /// </summary> /// <param name="routes">The collection of routes to be registered.</param> protected static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // Test route for the TenForce controller. routes.MapRoute( "TenForce", "api/TenForce", new { controller = "TenForce", action = "Index"} ); }
<div></div> </div>ignatandrei
All-Star
135148 Points
21679 Posts
Moderator
MVP
Re: Virtual Directory
Dec 02, 2010 12:13 PM|LINK
did you deploy also mvc dll?( are you using 1 or 2)?
Arne De Herd...
Member
1 Points
29 Posts
Re: Virtual Directory
Dec 02, 2010 12:17 PM|LINK
using MVC 2, and I've marked the DLL to be copied on build.
IvanLieckens
Participant
1189 Points
194 Posts
Re: Virtual Directory
Dec 02, 2010 12:21 PM|LINK
I advise checking the routing with http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx since it is very restrictive and possibly something is happening with the URL that is not expected.
IvanL, .NET Developer
Arne De Herd...
Member
1 Points
29 Posts
Re: Virtual Directory
Dec 02, 2010 12:24 PM|LINK
did it, resulted in 404 as well...as you mentioned on MSN, the routing isn't loaded at all.