I published my VS2008 ASP.NET MVC 1.0 project to a local folder, then FTPed it to a virtual directory on my host (GoDaddy). I attempted to run and it complained that System.Web.Mvc.dll is missing, so I copied that.
After that I get a 404. Now I know that it gets to my HomeController.Index method, because it does a RedirectToAction. That next action (which is in the same controller) is what causes the problem.
I have a feeling that the routing is not working correctly.
I watched the app with Fiddler:
- I goto http://www.mydomain.com/myApp
- Results in a 301 (permanent redirect) to http://www.mydomain.com/myApp
- Then I get a 302 (redirect to /myApp/Home/Details/2). This is correct because my Index method on the HomeController does a RedirectAction to the Details method with a parameter of 2.
- Then the browser hits http://www.mydomain.com/myApp/Home/Details/2. At this point I get a 404 Not found.
So it seems like /Home/Details/2 does not map onto my controller despite the following code being global.asax:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
So what am I missing?