0

So, I have implemented custom routing in mysite.

routes.MapRoute(
    "WithFriendlyNameOnly",
    "{friendlyName}",
    new { controller = "Home", action = "Redirect", friendlyName = String.Empty, id = UrlParameter.Optional },
    new { friendlyName = new MustBeFriendlyName() }
);

routes.MapRoute(
    "WithFriendlyNameDefault",
    "{friendlyName}/{controller}",
    new { controller = "Home", action = "Index", friendlyName = String.Empty, id = UrlParameter.Optional },
    new { friendlyName = new MustBeFriendlyName() }
);

routes.MapRoute(
    "WithFriendlyName",
    "{friendlyName}/{controller}/{action}/{id}",
    new { controller = "Home", action = "Redirect", friendlyName = String.Empty, id = UrlParameter.Optional },
    new { friendlyName = new MustBeFriendlyName() }
);

routes.MapRoute(
    "DefaultWithRule", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    new { controller = new MustNotRequireFriendlyName() }
);

This works fine locally. I am using the friendly name to determine your context in site site. Without it, all I give you is a 404 page.

My test environment is a Windows 2008 Server (IIS 7.5), and my application is in a subfolder like this: test.mydomain.com/mysite. Everything worked fine until I did this new custom url, so I'm fairly sure it isn't IIS or the server. However, my custom routes are not working at all. My regular routes are working just fine - like the home page, some information pages etc. It is only the pages with my custom routing. What did I do wrong?

Josh
  • 16,286
  • 25
  • 113
  • 158

1 Answers1

1

Have you tried to switch routes order making more specific at the beginning? It worked for me.

Try also that debugger: http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

Helps very much!

Slawomir Brys
  • 341
  • 3
  • 4