Search code examples
c#asp.net-mvcasp.net-mvc-4asp.net-mvc-routing

ASP.NET MVC 4 - RouteConfig.cs - updated locally, works - doesn't update on server


I have an asp.net MVC 4 app.

This is the RouteConfig.cs:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute("Home", "home", new { controller = "Home", action = "Index" });
        routes.MapRoute("Pricing", "pricing", new { controller = "Home", action = "Pricing" });
        routes.MapRoute("AboutUs", "aboutus", new { controller = "Home", action = "AboutUs" });


        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

I deployed this fresh to a Windows 2012 server. Worked fine. The routes remove /home/ from some URLs - eg:

mydomain.com/home/pricing

becomes

mydomain.com/pricing

After deployment I decided to add 3 new routs - for signup flow:

routes.MapRoute("SignUp", "SignUp", new { controller = "Myuser", action = "SignUp" });
routes.MapRoute("SignUp2", "SignUp2", new { controller = "Myuser", action = "SignUp2" });
routes.MapRoute("SignUpEnd", "SignUpEnd", new { controller = "Myuser", action = "SignUpEnd" });

Just above the Default route. They are there to change:

mydomain.com/myuser/signup

to

mydomain.com/signup

They worked fine locally. However when I deployed the new RouteConfig.cs to the server - none of the new routes are recognized (and the old ones still are).

I tried restarting the website in IIS, and different browsers even different computers - no effect.

I can find nothing on Google.

I feel like I'm missing something obvious - how can I get the updated routes to be recognized on the server?


Solution

  • You need to deploy MVC apps (as opposed to Web Forms 'websites') - only using the dlls in the Bin directory.

    Deploy the bin directory only - the site does not compile dynamically on the web server.

    Once I uploaded the Bin directory - it updated.