deploying MVC application

Last post 06-30-2008 4:50 AM by oazabir. 17 replies.

Sort Posts:

  • deploying MVC application

    04-27-2008, 7:43 PM
    • Loading...
    • tschreck
    • Joined on 03-06-2008, 9:04 PM
    • Posts 15

    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?

    Filed under:
  • Re: deploying MVC application

    04-28-2008, 1:18 AM
    • Loading...
    • mateo666
    • Joined on 03-12-2008, 10:22 PM
    • Posts 13

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

  • Re: deploying MVC application

    04-28-2008, 2:31 AM
    • Loading...
    • tschreck
    • Joined on 03-06-2008, 9:04 PM
    • Posts 15

    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. 


     

     
  • Re: deploying MVC application

    04-28-2008, 2:13 PM
    • Loading...
    • srulyt
    • Joined on 02-02-2008, 6:16 PM
    • Posts 208

    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

  • Re: deploying MVC application

    04-28-2008, 3:12 PM
    • Loading...
    • mateo666
    • Joined on 03-12-2008, 10:22 PM
    • Posts 13

     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? 

  • Re: deploying MVC application

    04-29-2008, 10:22 AM
    • Loading...
    • srulyt
    • Joined on 02-02-2008, 6:16 PM
    • Posts 208

    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

  • Re: deploying MVC application

    05-02-2008, 6:46 AM
    • Loading...
    • gyan_flip
    • Joined on 04-25-2008, 11:08 AM
    • बाघी - भोजपुर - बिहार - भारत
    • Posts 65

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

    ज्ञान [Gyan]
  • Re: deploying MVC application

    05-12-2008, 3:19 AM
    • Loading...
    • gayupk
    • Joined on 04-28-2008, 6:04 AM
    • Posts 56

    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.

  • Re: deploying MVC application

    05-12-2008, 3:39 AM
    • Loading...
    • huamiao
    • Joined on 04-24-2008, 7:44 AM
    • Posts 4

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

  • Re: deploying MVC application

    05-12-2008, 5:00 AM
    • Loading...
    • gayupk
    • Joined on 04-28-2008, 6:04 AM
    • Posts 56

    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.

  • Re: deploying MVC application

    05-12-2008, 5:24 AM
    • Loading...
    • huamiao
    • Joined on 04-24-2008, 7:44 AM
    • Posts 4

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

  • Re: deploying MVC application

    05-12-2008, 7:07 AM
    • Loading...
    • gayupk
    • Joined on 04-28-2008, 6:04 AM
    • Posts 56

    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

  • Re: deploying MVC application

    05-12-2008, 11:19 PM
    • Loading...
    • huamiao
    • Joined on 04-24-2008, 7:44 AM
    • Posts 4

    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.

  • Re: deploying MVC application

    05-13-2008, 12:33 AM
    • Loading...
    • gayupk
    • Joined on 04-28-2008, 6:04 AM
    • Posts 56

    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.

  • Re: deploying MVC application

    05-13-2008, 6:11 AM
    • Loading...
    • huamiao
    • Joined on 04-24-2008, 7:44 AM
    • Posts 4

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

Page 1 of 2 (18 items) 1 2 Next >