Sitefinity url routing question
Hi everybody,
I'm using Sitefinity 6.3 . I created a "Test" page in Sitefinity.
I want to use a site for Test with a parameter .so the URL would look like this:
1.) Url: /Test /model
Resolve to: /Test ?m=model
I have referred to the web site (http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/url-routing) , If I input "http://localhost:60876/test" ,it's OK.
But I input "localhost:60876/.../minco" , it will show empty.
This my sample code .
Global.asax:
protected void Application_Start(object sender, EventArgs e)
Telerik.Sitefinity.Services.SystemManager.ApplicationStart += new EventHandler<
EventArgs
>(SystemManager_ApplicationStart);
void SystemManager_ApplicationStart(object sender, EventArgs e)
CustomSitefinityRoute.RegisterType();
CustomSitefinityRoute.cs :
namespace SitefinityWebApp
public class CustomSitefinityRoute : SitefinityRoute
public override System.Web.Routing.RouteData GetRouteData(HttpContextBase httpContext)
//get the path from the httpContext variable and parse it
var virtuallPath = this.GetVirtualPathInternal(httpContext);
if (virtuallPath.Contains("test"))
//parse the acutal path to find the PageSiteNode from the sitemap provider
var sitemapProvider = this.GetSiteMapProvider();
if (sitemapProvider == null)
return null;
bool isAdditional;
string[] pars;
var node = sitemapProvider.FindSiteMapNode("test", false, out isAdditional, out pars);
if (node != null)
return this.GetRouteDataInternal(pars, httpContext.Request.QueryString, node);
return base.GetRouteData(httpContext);
public static void RegisterType()
ObjectFactory.Container.RegisterType<
SitefinityRoute
, CustomSitefinityRoute>();
Anybody can help me ?
Regards
Minco
Hello,
Sitefinity support parameters in the URL, so you can use it for this issue. Sitefinity will load the last valid page in the path of the requested URL and the rest of the URL will be treated as URL parameters. In your example, if you start with ~/test, no matter what you place after it, the test page will be loaded and you can access the rest in the URL as parameters.
If you have a custom control/widget that relies on this parameters in the URL, you have to add this line of code to indicate that you have processed a specific parameters:
Telerik.Sitefinity.Web.RouteHelper.SetUrlParametersResolved();
var
params
=
this
.Request.RequestContext.RouteData.Values[
"Params"
]
as
string
[];
if
(
params
!=
null
)
...