Route attributes in a page controller?

Vote:
 

Hello,

I'd like to ask what would be the best approach if I need a route attribute in a page controller (with longer routes behavior as it is). Is there a way how to do it or do I have to create my own routing template that would replace the Epi routing?

    public class ContactPageController : PageController<ContactPage>
    {
        public ActionResult Index(ContactPage currentPage)
        {
            var model = new ContactPageViewModel(currentPage);

            return View(model);
        }

        [Route("{area}")]
        public ActionResult ContactArea(ContactPage currentPage, string area = "")
        {
            var model = new ContactPageViewModel(currentPage, area);

            return View(model);
        }
    }

Thanks

Petr

#324865
Jul 03, 2024 13:46
Vote:
 

You can use a controller with custom URL parameters, you can also register a static route if you want a nicer URL format rather then the query string values.

If you need to do something more advanced you'd need to implement a partial router that starts routing at your specific page type and then "handles" all child routes below it.

https://docs.developers.optimizely.com/content-management-system/docs/partial-routing

#326609
Aug 06, 2024 9:12
* 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.