locked
deploying MVC application RRS feed

  • Question

  • User-1689198712 posted

    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?

    Sunday, April 27, 2008 7:43 PM

All replies

  • User146142360 posted

     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?? 

    Monday, April 28, 2008 1:18 AM
  • User-1689198712 posted

    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 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. 


     

     
    Monday, April 28, 2008 2:31 AM
  • User1046815810 posted

    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

    Monday, April 28, 2008 2:13 PM
  • User146142360 posted

     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? 

    Monday, April 28, 2008 3:12 PM
  • User1046815810 posted

    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

    Tuesday, April 29, 2008 10:22 AM
  • User1636651712 posted

    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");
            }
        } 

    Friday, May 2, 2008 6:46 AM
  • User-935163075 posted

    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.

    Monday, May 12, 2008 3:19 AM
  • User234961489 posted

    Did you try to add an application mapping for extension .mvc to aspnet_isapi.dll in iis manager?

    Monday, May 12, 2008 3:39 AM
  • User-935163075 posted

    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.

    Monday, May 12, 2008 5:00 AM
  • User234961489 posted

    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".

    Monday, May 12, 2008 5:24 AM
  • User-935163075 posted

    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

    Monday, May 12, 2008 7:07 AM
  • User234961489 posted

    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.

    Monday, May 12, 2008 11:19 PM
  • User-935163075 posted

    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.

    Tuesday, May 13, 2008 12:33 AM
  • User234961489 posted

    As my post before, did you un-check the checkbox "Check that file exists" in the mapping dialog?

    Tuesday, May 13, 2008 6:11 AM
  • User-935163075 posted

    yes I did but it is not working.. thanks

     

    Friday, May 16, 2008 2:50 AM
  • User-1857125468 posted
    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 :)
    Friday, June 20, 2008 9:19 AM
  • User-1422240412 posted
    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
    Monday, June 30, 2008 4:50 AM
  • User-745096912 posted

    iam trying to follow the guidelines provided here but iam unable to deploy the same. Please guide me ASAP.

    Monday, August 25, 2008 5:52 AM
  • User-924966505 posted
    I get the same problem,it make suck!
    Thursday, May 14, 2009 3:41 AM
  • User-924966505 posted
    I get the same problem,it make me suck!
    Thursday, May 14, 2009 3:41 AM
  • User-514194766 posted

    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

    Sunday, August 16, 2009 5:40 PM
  • User1079292066 posted

    Thanks it is working in iis6version

    routes.MapRoute("Basic",
                                    "{controller}.mvc/{action}/{id}",
                                    new { controller = "Home", action = "Index", id = "" },
                                    new { controller = @"[^\.]*" }
                               );
    routes.MapRoute"Default", // Route name

    "{controller}/{action}/{id}",

    // URL with parameters

    new { controller = "Home", action = "Index", id = "" }

    // Parameter defaults

    Tuesday, December 15, 2009 2:29 AM