Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Custom Route URL for custom controller

Vote:
 

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. "https://test.com/en-us/b/custom-url-5"

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?

Sincerely,

Abdellatif

#280765
May 23, 2022 10:09
Vote:
 

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.

#280872
May 25, 2022 14:59
Vote:
 

Thanks for replying Johan,

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

Greetings,

Abdellatif

#281267
Jun 02, 2022 12:05
Vote:
 

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)

#281268
Jun 02, 2022 12:34
Vote:
 

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: https://www.hiddenfoundry.com/thoughts/changing-query-string-parameter-to-a-friendly-segment-in-optimizely/

#281482
Jun 07, 2022 10:49
Vote:
 

@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)'?

Sincerely,

Abdellatif

#284142
Jul 21, 2022 15:02
Vote:
 

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.

#284147
Jul 21, 2022 15:41
Vote:
 

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.

#284201
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.