-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Listed at this url is an example of how Sitefinity is able to be extended to support custom url routing.
http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/url-routing
This works in non-feather projects, however we did encounter a bug when we were logged into the backend which occurred here: Telerik.Sitefinity.Web.UI.ScriptManagerWrapper.Page_InitComplete. We were able to get around this by disabling the in-line editor inside Administration > Settings > Pages > "Enable in-line editing." = false. I only note this so that if someone else runs across this, it may help them.
Additionally, for Feather projects, users may encounter a blank page when attempting to render a custom route. I believe the issue can be traced to this file: https://github.com/Sitefinity/feather/blob/master/Telerik.Sitefinity.Frontend/Resources/PackageManager.cs#L35 which obtains the current resource package. The method inspects both the Url and the PageInfo to obtain the current package, neither of which exist if you are using a virtual route (i.e. /my/custom/route/to/whatever)
As a result, the AddVariablesToPath() method inside LayoutVirtualPathBuilder.cs never applies the resource package (i.e. Bootstrap) to the virtual path. This in turn results in GetVirtualPath(IPageTemplate template) to return null because the layout is said not to exist.
To work around this, without making modifications to Telerik.Sitefinity.Frontend assembly, I was able to inject the following line of code in my method which returns RouteData just before my call to this.GetRouteDataInternal() [this assumes I am using Bootstrap for this instance].
SystemManager.CurrentHttpContext.Items["CurrentResourcePackage"] = "Bootstrap";
Finally, one last error I ran into, was despite disabling in-line editing as noted above, the following line in the default Bootstrap template caused a NullReferenceException when LayoutRenderer.RenderViewToString made a call to Render() the razor view:
@Html.InlineEditingManager(false)
Once I removed this line, the NullReferenceException was avoided, and the view rendered properly for my custom routes.
Hope this helps!