Custom Route URL for custom controller


Hello There,

As a developer I want to create a custom routing for my controller. This controller is created outside of the EPi CMS.

ex. ""

routes.MapRoute("sample", "{language}/b/{friendlyUrl}-{id}", new {controller = "Sample", action = "Index"})

Is there something wrong with the routing setup? or am I missing another configuration?



May 23, 2022 10:09

I'm not a 100% on this but I recall always failing when the first part is something dynamic.

Try putting "b/" first in the pattern and you will probably see it working.

May 25, 2022 14:59

Thanks for replying Johan,

Sadly enough this did not do the trick, are there any other possibilities? 



Jun 02, 2022 12:05

Maybe try a catch-all and then split the value in controller?

routes.MapRoute("sample", "b/{*path}", new {controller = "Sample", action = "Index"})

And then have something like Index(string path)

Jun 02, 2022 12:34

Try creating a page and a page controller but no view. That way you use Optimizely's built in MapContentRoute to worry about the language segment for you.

In terms of making the id part of the friendly url, use a Partial Router:

Jun 07, 2022 10:49

@Surjit Bharath,

Sadly all of model information is not available in Epi, all of the information comes from our external API.

We need to use our controller just for managing this page, because of that we could not use the IPartialRouter.

Are there other ways to do this without using 'Epi Data structure (IContent)'?



Jul 21, 2022 15:02

I'm assuming your Controller is then just a standard mvc controller? and since you don't want it relying on IContent then your url should be fixed?

In which case you see Johan's comment about the catch all routing then registering last.

Jul 21, 2022 15:41

Yes, we want to create a standard MVC controller with standard route path and create a page with this controller, without Epi integration.

We already tried Johans proposal, and that did not work for us.

Jul 22, 2022 7:59
* 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.