November Happy Hour will be moved to Thursday December 5th.

Exclude routing of content pages

Vote:
 

I'm sure this has been talked about before, but I've had no luck finding a satisfactory answer.

What I need to do is to prevent EPI from touching my content pages - I have the following:

webpage/containerpage/contentpage where webpage/containerpage/ is an epi page but the contentpages are not, which means I get 404 on all contentpages...

What is the best/easiest way to prevent this from happening?

Epi CMS 10.2.0.0

#190544
Apr 11, 2018 18:29
Vote:
 

Off the top of my head these content pages are MCV Controllers you can

  1. Create an InitializationModule
  2. Use the RouteTable to add a route through to your non episerver controllers (https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/creating-custom-routes-cs)

Example (Untested) to route these page request to a Content page controller

    [ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
    public class ContentPageRoutingInitializationModule : IInitializableModule
    {
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <remarks>Gets called as part of the EPiServer Framework initialization sequence. Note that it will be called
        /// only once per AppDomain, unless the method throws an exception. If an exception is thrown, the initialization
        /// method will be called repeadetly for each request reaching the site until the method succeeds.</remarks>
        public void Initialize(InitializationEngine context)
        {
            MapRoutes(RouteTable.Routes);
        }

        /// <summary>
        /// Maps the routes.
        /// </summary>
        /// <param name="routes">The routes.</param>
        private static void MapRoutes(RouteCollection routes)
        {
            routes.MapRoute(
                "cotent-pages",                                           // Route name
                "webpage/containerpage/{page}",                           // URL with parameters
                new { controller = "Content", action = "Index" }  // Parameter defaults
            );
        }

        /// <summary>
        /// Resets the module into an uninitialized state.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <remarks><para>
        /// This method is usually not called when running under a web application since the web app may be shut down very
        /// abruptly, but your module should still implement it properly since it will make integration and unit testing
        /// much simpler.
        /// </para>
        /// <para>
        /// Any work done by <see cref="M:EPiServer.Framework.IInitializableModule.Initialize(EPiServer.Framework.Initialization.InitializationEngine)" /> as well as any code executing on <see cref="E:EPiServer.Framework.Initialization.InitializationEngine.InitComplete" /> should be reversed.
        /// </para></remarks>
        public void Uninitialize(InitializationEngine context) { /*uninitialize*/}

        /// <summary>
        /// Preloads the specified parameters.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        public void Preload(string[] parameters) { }

    }

[Pasting files is not allowed]

#190565
Edited, Apr 12, 2018 9:50
Vote:
 

Thanks, I'll see what I can come up with.

#190603
Apr 12, 2018 15:33
Vote:
 

Have a look at this (if I understand your question correctly)

https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Routing/Partial-routing/Partial-routing/

#190604
Apr 12, 2018 16:36
* 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.