How to creat a URL Based on a Matching Route
Is there anybody who knows?
Hi Minco Zhou,
Thank you for contacting us.
In ASP.NET you would register your routes directly to the RouteTable.Routes collection on Application_Start in your Global.asax, this is too early for a Sitefinity application as it has not yet initialized all of its components, which happens on Bootstrapping. So actual Routes registration in Sitefinity happens inside our implementation of the RegisterRoutes method of the above discussed Telerik.Sitefinity.Abstractions.Bootstrapper class. When you hook to the Bootstrapper.Initialized event you have to filter by the CommandName argument of the event, to be able to plug your logic after the execution of our RegisterRoutes logic.
To put it more clearly - if you want 'yoursitedomain/customroute' to open the 'CustomPage.aspx' you'll need something like this:
protected
void
Application_Start(
object
sender, EventArgs e)
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += Bootstrapper_Initialized;
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
if
(e.CommandName ==
"RegisterRoutes"
)
//register route to the physical page ~/CustomPage.aspx
System.Web.Routing.RouteTable.Routes.MapPageRoute(
"CustomPageRoute"
,
"customroute"
,
"~/CustomPage.aspx"
);