I'm trying to deploy a MVC application onto a server for demonstration purposes. I can access the MVC application without a problem using localhost. I get a 404 error when accessing any URL other then the default URL after publishing MVC app to new server.
The new server has the latest version of MVC and .Net 3.5 installed. I can access the default URL which tells me that MVC is working, but any other link fails. Why would the app work using localhost:[port number] and not the url for the dev server? How
can you trouble shoot this? I even migrated the "default" MVC application that's created for new MVC projects to the server and I get the same issue when clicking on the About url. Any ideas?
1 // Note: Change the URL to "{controller}.mvc/{action}/{id}" to enable 2 // automatic support on IIS6 and IIS7 classic mode
So, what are the rules around where .mvc can be added in new Route? The instructions just say to place it after {controller}, however, I have several routes that
do not signify a {controler} in the route pattern. How do you handle .mvc in this situation? need some advice. Thanks for your help.
IIS7 has a mode called "integrated mode". Integrated mode can call an ASP.NET Http Module without invoking the ASP.NET asapi dll. This allows IIS7 to route the extension-less urls. In IIS6 and II7 running classic pipeline mode IIS cannot check the rout without
invoking the ASP.NET isapi dll. The problem is that IIS does not know to invoke the ASP.NET isapi dll unless it sees an extension associated with ASP.NET. The default MVC routes are extension-less therefore IIS does not know what to do with them.
This explains the problem.
The solution is to add an ASP.NET extension to your urls (.mvc, .aspx, etc...). It doesn't matter where in your route you add the extension (after your controller, at the end, where ever you want) as long as you add it.
Another option is to use wildcard associations and to have all requests coming to your server be routed to the ASP.NET isapi dl. this has some performance issues but it will allow you to keep your pretty extension-less urls even in IIS6
routes.MapRoute("Basic",
"{controller}.mvc/{action}/{id}",
new { controller = "Home", action = "Index", id = "" },
new { controller = @"[^\.]*" }
);
routes.MapRoute("Default",
"Default.aspx",
new { controller = "Home", action = "Index", id = "" }
);
In IIS 5 i have a virtual directory pointing to my web app with the name GTS
Whenever i try to browse from localhost i get
The resource cannot be found.
Description:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
is the built in VS webserver all request are sent to ASP.NET so even if the url is extension-less it gets executed. In IIS urls are only sent to ASP.NET if they have a file extension associated with ASP.NET.
To run your app you must have an extension associated with ASP.NET in your routes.
Try changing the .mvc to .aspx and see if this fixes it
I am using IIS7 and the following routeer code in global.asax.cs file:
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
"Basic", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" }, // Parameter defaults
new { controller = @"[^\.]*" } // Parameter constraints
);
routes.MapRoute("Default",
"Default.aspx",
new { controller = "Home", action = "Index", id = "" }
);
}
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
It is working fine for me. Do you have added Default.aspx and Default.aspx.cs page as below:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="namespaceName._Default" %>
<%-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --%>
public partial class _Default : Page
{ public void Page_Load(object sender, System.EventArgs e)
{
Response.Redirect("~/Home");
}
}
I am sorry but I did not understand. What exactly am I supposed to do?
It's in inetmgr>web sites>Properties>HomeDirectories>Configuration>add>Executable and extension. Am I doing it right? This is where the OK button is not enabled.
Yes, you are right here, when you add the mapping, choose the executable first and then fill the extentsion. After that, you find the OK button is not enabled, that's it. Try to move your mouse point to the text box of executable and click your mouse, it'll
set the focus on the textbox. If you are lucky enough, you'll find that you can click the OK button now.
Or
There is another way, try to input the path and the file name of the executable by your self but not browse it.
So does this mean that all the IIS urls need to contain .mvc like this? http://localhost/NorthwindDemo/Products.mvc/List/Beverages edit: here is a solution, not exactly effortless though http://www.flux88.com/UsingASPNETMVCOnIIS6WithoutTheMVCExtension.aspx
I hope to see a fix for the .mvc problem in a ASP.NET MVC release soon :)
The followng blog post suggests a solution to the 404 problem on IIS 6.0: http://msmvps.com/blogs/omar/archive/2008/06/30/deploy-asp-net-mvc-on-iis-6-solve-404-compression-and-performance-problems.aspx
are you using IIS 6 (windows sever 2003) ?? or IIS 7 classic mode ? if so you might want to check this : http://www.asp.net/learn/mvc/tutorial-08-cs.aspx
if this post unswerd ur question marke it as answer
Member
3 Points
18 Posts
deploying MVC application
Apr 27, 2008 07:43 PM|tschreck|LINK
I'm trying to deploy a MVC application onto a server for demonstration purposes. I can access the MVC application without a problem using localhost. I get a 404 error when accessing any URL other then the default URL after publishing MVC app to new server. The new server has the latest version of MVC and .Net 3.5 installed. I can access the default URL which tells me that MVC is working, but any other link fails. Why would the app work using localhost:[port number] and not the url for the dev server? How can you trouble shoot this? I even migrated the "default" MVC application that's created for new MVC projects to the server and I get the same issue when clicking on the About url. Any ideas?
MVC deployment
None
0 Points
23 Posts
Re: deploying MVC application
Apr 28, 2008 01:18 AM|mateo666|LINK
Hey i was just having the same problem and found this thread.
Default render a blank page but every other links dont work.
My default route is not redirecting neither to what it is supposed Home/Index. This behavior is also the same when i debug in vs?
Anyone??
Member
3 Points
18 Posts
Re: deploying MVC application
Apr 28, 2008 02:31 AM|tschreck|LINK
I found in Global.asax that you are supposed to add .mvc to the route like this (line 1):
1 routes.Add("SearchResults", new Route(".mvc/searchresults/{ticks}/{mealtypeid}/{viewsource}/{foodgroupid}/{foodname}", new MvcRouteHandler())
2 {
3 Defaults = new RouteValueDictionary(new
4 {
5 controller = "Search",
6 action = "SearchResults",
7 foodgroupid = 0,
8 foodname = ""
9 }),
10 });
The default instructions in Global.asax says to:
1 // Note: Change the URL to "{controller}.mvc/{action}/{id}" to enable2 // automatic support on IIS6 and IIS7 classic mode So, what are the rules around where .mvc can be added in new Route? The instructions just say to place it after {controller}, however, I have several routes that do not signify a {controler} in the route pattern. How do you handle .mvc in this situation? need some advice. Thanks for your help.
Member
675 Points
230 Posts
Re: deploying MVC application
Apr 28, 2008 02:13 PM|srulyt|LINK
IIS7 has a mode called "integrated mode". Integrated mode can call an ASP.NET Http Module without invoking the ASP.NET asapi dll. This allows IIS7 to route the extension-less urls. In IIS6 and II7 running classic pipeline mode IIS cannot check the rout without invoking the ASP.NET isapi dll. The problem is that IIS does not know to invoke the ASP.NET isapi dll unless it sees an extension associated with ASP.NET. The default MVC routes are extension-less therefore IIS does not know what to do with them.
This explains the problem.
The solution is to add an ASP.NET extension to your urls (.mvc, .aspx, etc...). It doesn't matter where in your route you add the extension (after your controller, at the end, where ever you want) as long as you add it.
Another option is to use wildcard associations and to have all requests coming to your server be routed to the ASP.NET isapi dl. this has some performance issues but it will allow you to keep your pretty extension-less urls even in IIS6
Good Luck
None
0 Points
23 Posts
Re: deploying MVC application
Apr 28, 2008 03:12 PM|mateo666|LINK
Not sure i'm following you here.
My routes are defined like this
routes.MapRoute("Basic",
"{controller}.mvc/{action}/{id}",
new { controller = "Home", action = "Index", id = "" },
new { controller = @"[^\.]*" }
);
routes.MapRoute("Default",
"Default.aspx",
new { controller = "Home", action = "Index", id = "" }
);
In IIS 5 i have a virtual directory pointing to my web app with the name GTS
Whenever i try to browse from localhost i get
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.Requested URL: /gts/Home.mvc
If i try from vs everything is fine?
Member
675 Points
230 Posts
Re: deploying MVC application
Apr 29, 2008 10:22 AM|srulyt|LINK
is the built in VS webserver all request are sent to ASP.NET so even if the url is extension-less it gets executed. In IIS urls are only sent to ASP.NET if they have a file extension associated with ASP.NET.
To run your app you must have an extension associated with ASP.NET in your routes.
Try changing the .mvc to .aspx and see if this fixes it
Member
31 Points
76 Posts
Re: deploying MVC application
May 02, 2008 06:46 AM|gyan_flip|LINK
I am using IIS7 and the following routeer code in global.asax.cs file:
It is working fine for me. Do you have added Default.aspx and Default.aspx.cs page as below:public partial class _Default : Page
{
public void Page_Load(object sender, System.EventArgs e)
{
Response.Redirect("~/Home");
}
}
None
0 Points
57 Posts
Re: deploying MVC application
May 12, 2008 03:19 AM|gayupk|LINK
I am using IIS 5 . The error is 404. I added .mvc in controller but still it isn't working. Do i need to have a wildcard? If so how?
Kindly help.
None
0 Points
4 Posts
Re: deploying MVC application
May 12, 2008 03:39 AM|huamiao|LINK
Did you try to add an application mapping for extension .mvc to aspnet_isapi.dll in iis manager?
None
0 Points
57 Posts
Re: deploying MVC application
May 12, 2008 05:00 AM|gayupk|LINK
It is not allowing me to add the extension.
.mvc extension i mean. The ok button is not enabled for me to add the extension.
None
0 Points
4 Posts
Re: deploying MVC application
May 12, 2008 05:24 AM|huamiao|LINK
For this issue, you may just try to click the textbox of the executable after you fill the executable and extension out.
It is incredible but that's the truth.
Oh, one more thing is do not forget to un-check the checkbox "Check that file exists".
None
0 Points
57 Posts
Re: deploying MVC application
May 12, 2008 07:07 AM|gayupk|LINK
I am sorry but I did not understand. What exactly am I supposed to do?
It's in inetmgr>web sites>Properties>HomeDirectories>Configuration>add>Executable and extension. Am I doing it right? This is where the OK button is not enabled.
Thank you
None
0 Points
4 Posts
Re: deploying MVC application
May 12, 2008 11:19 PM|huamiao|LINK
Yes, you are right here, when you add the mapping, choose the executable first and then fill the extentsion. After that, you find the OK button is not enabled, that's it. Try to move your mouse point to the text box of executable and click your mouse, it'll set the focus on the textbox. If you are lucky enough, you'll find that you can click the OK button now.
Or
There is another way, try to input the path and the file name of the executable by your self but not browse it.
Good luck.
None
0 Points
57 Posts
Re: deploying MVC application
May 13, 2008 12:33 AM|gayupk|LINK
thank you huamiao, it worked. I typed the path instead of browsing.
But my mvc application is not working even after adding .mvc to my controller.
None
0 Points
4 Posts
Re: deploying MVC application
May 13, 2008 06:11 AM|huamiao|LINK
As my post before, did you un-check the checkbox "Check that file exists" in the mapping dialog?
None
0 Points
57 Posts
Re: deploying MVC application
May 16, 2008 02:50 AM|gayupk|LINK
yes I did but it is not working.. thanks
None
0 Points
2 Posts
Re: deploying MVC application
Jun 20, 2008 09:19 AM|indiekiduk|LINK
Member
20 Points
7 Posts
Re: deploying MVC application
Jun 30, 2008 04:50 AM|oazabir|LINK
ASP.NET MVC
Omar AL Zabir
http://omaralzabir.com
None
0 Points
5 Posts
Re: deploying MVC application
Aug 25, 2008 05:52 AM|signonpankaj|LINK
iam trying to follow the guidelines provided here but iam unable to deploy the same. Please guide me ASAP.
None
0 Points
2 Posts
Re: deploying MVC application
May 14, 2009 03:41 AM|C_XIII|LINK
None
0 Points
2 Posts
Re: deploying MVC application
May 14, 2009 03:41 AM|C_XIII|LINK
Participant
814 Points
334 Posts
Re: deploying MVC application
Aug 16, 2009 05:40 PM|yassir.2|LINK
are you using IIS 6 (windows sever 2003) ?? or IIS 7 classic mode ? if so you might want to check this : http://www.asp.net/learn/mvc/tutorial-08-cs.aspx
None
0 Points
1 Post
Re: deploying MVC application
Dec 15, 2009 02:29 AM|lucky_09|LINK
Thanks it is working in iis6version
routes.MapRoute("Basic",
"{controller}/{action}/{id}","{controller}.mvc/{action}/{id}",
new { controller = "Home", action = "Index", id = "" },
new { controller = @"[^\.]*" }
);
routes.MapRoute"Default", // Route name
// URL with parameters
new { controller = "Home", action = "Index", id = "" }// Parameter defaults