Reputation:
i have the application on environment in IIS 5.1 under "localhost/mvcapplication1"
The routing configuration is something like:
routes.MapRoute("mvc-default", "{controller}.mvc/{action}/{id}"
, new { controller = "Home", action = "Index", id = (string)null });
routes.MapRoute("Root", ""
, new { controller = "Home", action = "Index", id = (string)null });
When the page is routed via "Root", the links on the views will point to
http://localhost/mvcapplication1/MvcApplication1/Product.mvc
, which obviously it doesn't exist. However when the first "mvc-default" is used, it works well.
If the application is hosted under http://......./ would also work well.
any hints about how to solve it?
Thanks.
Upvotes: 0
Views: 679
Reputation: 870
a year late, but maybe this will help someone else. i had the same issue, as we use IIS6, and i got it to work by having these two entries as the last two listed in my routing config:
routes.MapRoute(null, "{controller}.aspx/{action}");
routes.MapRoute(
"Default", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
change the ".aspx" to your ".mvc" or whatever you need it to be.
Upvotes: 0
Reputation: 1065
Maybe this works:
Change:
HttpContext.Current.RewritePath(Request.ApplicationPath);
to
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
in default.aspx.cs (or default.aspx.vb)
Upvotes: 0
Reputation: 1065
You're encountering 404 error because you've set the routing rule "{controller}.mvc/{action}/{id}", which obviously adds .mvc extension after the controller name, and the "" routing rule wouldn't take precede, even work because you're using unconfigured IIS.
To fix it without configuring IIS, you can change .mvc to something ASP.Net currently handles, like .aspx, .asmx, or something else.
If you want a fix for IIS, visit links below, follow the instructions, and remove the .mvc extension.
ASP.Net
Phil Haack's blog
You can find more posts about it if you just Google about it.
Upvotes: 2