Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
I've you create an Episerver Initialization module https://world.episerver.com/documentation/developer-guides/CMS/initialization/Creating-an-initialization-module/ you can then add the route to your standard MVC controller in the RouteCollection.
/// <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 void MapRoutes(RouteCollection routes)
{
routes.MapRoute(null, "notify-payment", new { controller = "PaymentNotification", action = "Index" });
}
This adds a route to my controller inheriting from a standard MVC controller
public class PaymentNotificationController : Controller
{
/// <summary>
/// Method to handle an external notification POST from a payment provider
/// </summary>
/// <returns>An instance of HttpStatusCodeResult</returns>
[HttpPost]
[AllowAnonymous]
[ValidateInput(false)]
public ActionResult Index()
{
}
}
An alternative is to override RegisterRoutes In your Global.cs file, then you can control wether your custom route should be inserted before or after the EPiServer routes.
I have a need to define an MVC Route that won't go through the Epi pipeline. But, currently there's no place in my project were I see other routes defined.
I am guessing most of it is happening in the Epi classes. I know where they go in a standard MVC 5 project, but my Epi project seems different.