Try our conversational search powered by Generative AI!

MapContentRoute not picked up by routing

Vote:
 

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?

 

Thanks

#69550
Mar 27, 2013 11:28
Vote:
 

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.

#69553
Mar 27, 2013 11:49
Vote:
 

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

 

#69554
Mar 27, 2013 11:58
Vote:
 

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/

#69555
Mar 27, 2013 12:29
Vote:
 

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?

#69557
Mar 27, 2013 12:52
Vote:
 

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!

#69565
Edited, Mar 27, 2013 15:06
Vote:
 

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.

#69580
Mar 28, 2013 9:14
Vote:
 

Thanks!

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?

#69796
Edited, Apr 05, 2013 18:44
Vote:
 

For anyone else trying this: the code is :

	var mapRouteParameters = new MapContentRouteParameters();
	mapRouteParameters.UrlSegmentRouter =
	  new DefaultUrlSegmentRouter(ServiceLocator.Current.GetInstance<IContentLoader>(),
	  new LanguageSelectorFactory(), 
	  ContentReference.StartPage,
	  ServiceLocator.Current.GetInstance<IRoutingSegmentLoader>());

    

#71461
May 20, 2013 11:40
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.