However if I edit the node in Umbraco the changes does'nt kick in when I render the page via the custom Url. (I do see the changes when using the default Umbraco Url though)
Is it a bug, or do I miss something...? - my files are listed below :-|
RegisterCustomRouteComposer.cs:
using Umbraco.Core;
using Umbraco.Core.Composing;
using UmbracoVIII.Core.Components;
using UmbracoVIII.Core.Controllers;
namespace UmbracoVIII.Core.Composers
{
public class RegisterCustomRouteComposer : IUserComposer
{
public void Compose(Composition composition)
{
composition.Components().Append<RegisterCustomRouteComponent>();
}
}
}
RegisterCustomRouteComponent.cs:
using System.Collections.Generic;
using System.Web.Routing;
using Umbraco.Core.Composing;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web;
using Umbraco.Web.Mvc;
using Umbraco.Web.PublishedCache;
using UmbracoVIII.Core.Helpers.Urls;
namespace UmbracoVIII.Core.Components
{
public class RegisterCustomRouteComponent : IComponent
{
private readonly IUmbracoContextFactory _context;
public RegisterCustomRouteComponent(IUmbracoContextFactory context)
{
_context = context;
}
public void Initialize()
{
using (var cref = _context.EnsureUmbracoContext())
{
IPublishedContentCache umbracoHelper = cref.UmbracoContext.Content;
IEnumerable<IPublishedContent> categoryListing = umbracoHelper.GetByXPath("//categoryitem");
foreach (var item in categoryListing)
{
RouteTable.Routes.MapUmbracoRoute(
name: "CategoryItem-" + item.Id,
url: UrlHelpers.GetCategoryItemUrl(item.Id).TrimStart('/'),
new
{
controller = "Categoryitem",
action = "Categoryitem"
},
new CategoryitemHandler(item));
}
}
}
public void Terminate()
{
//throw new NotImplementedException();
}
}
public class CategoryitemHandler : UmbracoVirtualNodeRouteHandler
{
private readonly IPublishedContent _node;
public CategoryitemHandler(IPublishedContent node)
{
_node = node;
}
protected override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
{
return _node;
}
}
}
CategoryitemController.cs:
using System.Web.Mvc;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
namespace UmbracoVIII.Core.Controllers
{
public class CategoryitemController : RenderMvcController
{
public ActionResult Categoryitem(ContentModel model)
{
return CurrentTemplate(model);
}
}
}
Odd Caching issue with Custom Routing
I have followed this example from the documentation regardingCustom Routing, and it works quite well for me: https://our.umbraco.com/documentation/reference/routing/custom-routes
However if I edit the node in Umbraco the changes does'nt kick in when I render the page via the custom Url. (I do see the changes when using the default Umbraco Url though)
Is it a bug, or do I miss something...? - my files are listed below :-|
RegisterCustomRouteComposer.cs:
RegisterCustomRouteComponent.cs:
CategoryitemController.cs:
is working on a reply...