Can Episerver Search Coexist with Default MVC Routes?

Brian Oliver
Advanced Developer

I was hitting a brick wall recently when implementing Episerver search.  I could see that items were being queued up to be indexed:

<p> CODE:</p>

However, the queue wasn’t being processed.  The number of items should be zero once everything has been indexed.

First, I tried browsing to the /indexingService/indexingService.svc and got the expected “Endpoint not found” message in my browser:

Endpoint Not Found

So far, so good.  Next, I tried to hit one of the endpoints:  /indexingService/indexingService.svc/search/?q=videos&namedindexes=default&format=xml&offset=0&limit=50&accesskey=local

I expected to get a big xml dump of the search results, but instead I got a 404 response:

Server Error: 404 Error

The first clue came from the Episerver log file:

<p> CODE:</p>

Notice that last message?  The site is thinking that the search endpoint is an MVC route.  I checked the site’s global.asax, and sure enough, standard MVC routes are being used in addition to the Episerver routes.

<p> CODE:</p>

When I take out the call to MapRoute, the endpoints start working:

Working Endpoints

I couldn’t just take that out, however, because other developers on my team were counting on that so that their custom AJAX web services would work.  In the end, this problem was solved with a call to IgnoreRoute. Take note of where this call is made, because it absolutely must come before the call to MapRoute; otherwise it just won’t work.

<p> CODE:</p>

Insights, Right to Your Inbox.