I have a strange problem that the episerver routing is not working for MapContentRoute in a specific project. I have tried the same code in another episerver demo project and it worked - so i presume something must be interfering with this one.
The project im trying to integrate with is a huge beast so theres a lot of old legacy code. but i have tried commenting out any handlers, filters etc but with no success. The routing is working because i can access episerver page urls, but the custom route i add does not get picked up and throws a 404. I can see it registered in the routes table, but have no idea how to debug this and find out what is happening.
What could be interfering with the routing and how could i debug this?
Does your not working project use a custom FURL provider?
That is if you look in config, which FurlProvider is used? And also which routing HttpModule is registered, is it EPiServer.Web.RoutingUrlRewriteModule or EPiServer.Web.UrlRewriteModule?
What I am thinking is that there is a FURL module that handles the request before the routes get a chance.
This is what is registered
<add name="InitializationModule" type="EPiServer.Framework.Initialization.InitializationModule, EPiServer.Framework" preCondition="managedHandler" />
<add name="UrlRewriteModule" type="EPiServer.Web.RoutingUrlRewriteModule, EPiServer" preCondition="managedHandler" />
<add name="ShellRoutingModule" type="EPiServer.Shell.Web.Routing.ShellRoutingModule, EPiServer.Shell" />
<remove name="WebDAVModule" />
I have compared the 2 web configs and cannot spot any obvious differences
I've just tried using this tool : http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx
and i can see my route in the table, but there is no match at all. it (obviously) shows a match for the usual episerver urls.
Johan, i am using your example /shop/ route from http://world.episerver.com/Blogs/Johan-Bjornfot/Dates1/2012/10/EPiServer7--Routing/
Is your route registered before the builtin EPiServer routes or after? If after you could try to register it before. It should not do any difference but just to make sure it is not the built in routes that hijacks the request.
Otherwise it seems like it is something that "handles" the request and returns a 404 before the routes get a chance, the question is what that is?
ok, so a bit more investigation and I realised that the routing is actually semi-working, but its routing through to the wrong content tree.
i have UK, US and Australia sites set up. Im accessing the UK site, but it is attempting to deliver the content from the Australia branch. which explains the 404. If i create the page structure in Australia, it delivers that content... despite the url pointing to the uk site.
Australia is the last <Site> in my episerver config. If I make UK the last site, then the content is delivered from the uk branch!!! it doesnt seem to be using the url to work out what site is active!
You can specifiy the content root from where your routing should start. You do this by assiging property UrlSegmentRouter on MapContentRouteParameters. You can assign it an instance of DefaultUrlSegmentRouter where you can assing the routing root in constructor parameter.
Whats the quickest way to do this ? (lest code?) it seems like a bug to me that the order of the <site> elements affects which it uses by default?
For anyone else trying this: the code is :
var mapRouteParameters = new MapContentRouteParameters();