I'm looking to do something similar to this post:
How to hide controller name in Url?
only without any sort of ID.
The server is running IIS 6 and the pages already show up without extensions so it's not a wildcard issue.
I'm looking to hit http://website.com/action-name
I have http://website.com/controller/action-name working
I'm assuming this is just a simple routing change that I am somehow goofing up. My current routing rule is:
routes.MapRoute(
"RouteName",
"{action}",
new { controller = "Home", action = "Index" }
);
Is your new routing rule positioned above the default routing rule of {controller, action, id}
so that it has the opportunity to match first?
The problem is your default route is still probably in place so it is matching it first and defaulting the rest of the inputs it expects. Based on your comment that the controller/action
is working makes me think you didn't remove it or it is appearing first. Can you post your entire RegisterRoutes
?
Try making the route you defined the very first route and it should match almost anything you pass at it.
EDIT: Added what your RegisterRoutes
should look like:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// This will match anything so if you have something very specific with hard coded
// values or more items that will need to be match add them here above but do not
// add defaulted values so it can still fall through to this.
routes.MapRoute(
"RouteName",
"{action}",
new { controller = "Home", action = "Index" });
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With