views:

11

answers:

1

I have an existing ASP.Net Application, into which I am attempting to introduce MVC2.

Hopefully I can remember the steps, but what I did was the following:

  1. Created a dummy MVC2 project.
  2. Compared and merged .csproj, resulting in the Add Item commands showing MVC2 items.
  3. Compared and merged the web.config
  4. Compared and merged the global.asax.cs
  5. Added Models, Views and Controllers directories
  6. Added HostController with Index action and Index.aspx (no logic)
  7. Amended route to make /Host/Index the default

So now, when I access the application via the root address http://localhost/MyApp it all works.

But, when I access http://localhost/MyApp/Host/Index I get a 404 error. I get the same result for any of the Controller/Actions I created. The only way I can get them to appear is to use the defaults in the routing configuration. I installed Phill Haack's route debugger and it's doing nothing. Obviously there's some problem with my routing, but I can't figure it out.

Any ideas what I've missed?

A: 

Bah... turns out that this is to do with IIS 5.1 and MVC routing.

I resolved it by using the following Routes in my application (note the .aspx extensions).

routes.MapRoute("Root", "", new { controller = "Host", action = "Index" });
routes.MapRoute("Default", "{controller}/{action}.aspx", new { controller = "Host", action = "Index" });

Means I can't have clean routes, but at least it works.

Chris Kemp