Custom routes with virtual paths
Hi
Can someone please assist, I've been doing a lot of research on how to get this to work, but can't seem to get it to work. I have the same issue as David here : www.sitefinity.com/.../url-routing
The problem is when adding custom routing that I get a 404 error, but I am sure its because the page does not exists, its a virtual page created via the backend of Sitefinity with a custom usercontrol on the page handling the logic.
How can I handle custom routes in Sitefinity 6?
I have this :
www.mysite.com/pagename
When I search for "Shoes" on this page it needs to display as :
www.mysite.com/pagename/categories/shoes
So what I wanted to do was create custom routes for this, but I can't seem to get this to work.
I tried this :
Global.asax
protected void Application_Start(object sender, EventArgs e)
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
Custom handler:
public class CustomHttpHandler : IRouteHandler
public CustomHttpHandler(string virtualPath)
this.VirtualPath = virtualPath;
public string VirtualPath get; private set;
public IHttpHandler GetHttpHandler(RequestContext requestContext)
var page = BuildManager.CreateInstanceFromVirtualPath(VirtualPath, typeof(Page)) as IHttpHandler;
return page;
public bool IsReusable
get return false;
Routes:
void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
if (args.CommandName == "RegisterRoutes")
var routes = ((EnumerableQuery<RouteBase>)args.Data).ToList();
routes.Insert(0, new System.Web.Routing.Route("blog/category/Category", new CustomHttpHandler("/blog")));
Kind Regards,
Gerrit
Hi Gerrit,
You can take a look on the similar issue discussed in that forum thread:
http://www.sitefinity.com/developer-network/forums/general-discussions-/url-routing-in-sitefinity-5-0
Regards,
Svetoslav Manchev
Telerik
Thank you Svetoslav,
We ended up to go a different route because of this issue. For those who have trouble with this, for us it work by adding additional URL's to the specific page, and then redirecting to the additional url.
Kind Regards,