How can i extend my own routes along side sitefinity 6
hello,
I have been trying to extend my own routes along side with sitefinity 6. I created a custom route handler but sitefinity gives a 404 error.
What I am attempting to do is to reroute:
"mydomain.com/myPage.aspx?id=34" to
"mydomain.com/myPage/34"
This is how my custom route handler looks like:
namespace SitefinityWebApp
public class SiteRouteHandler : IRouteHandler
public IHttpHandler GetHttpHandler(RequestContext requestContext)
return BuildManager.CreateInstanceFromVirtualPath("~/myPage.aspx", typeof(Page)) as IHttpHandler;
void Application_Start(object sender, EventArgs e)
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<
Telerik.Sitefinity.Data.ExecutedEventArgs
>(Bootstrapper_Initialized);
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("myPage" + "/ID", new SitefinityWebApp.SiteRouteHandler()));
Hello Chris,
Please check this forum thread, where the same problem is discussed:
http://www.sitefinity.com/developer-network/forums/general-discussions-/httphandler-not-working#1501414
First of all, you need to create a RouteHanlder, where you will call your HttpHandler:
public
class
myRouteHandler : IRouteHandler
public
IHttpHandler GetHttpHandler(RequestContext requestContext)
// Return your HttpHandler implementation
return
new
MyHttpHandler();
public
class
MyHttpHandler : IHttpHandler, IRequiresSessionState
public
bool
IsReusable
get
return
false
;
public
void
ProcessRequest(HttpContext context)
var id = context.Request.QueryString[
"id"
];
context.Response.Redirect(
"/test"
,
true
);
protected
void
Session_Start(
object
sender, EventArgs e)
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized +=
new
EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
if
(args.CommandName ==
"RegisterRoutes"
)
var routes = (System.Web.Routing.RouteCollection)args.Data;
routes.Add(
"MyRoute"
,
new
System.Web.Routing.Route(
"/myPage.aspx"
,
new
myRouteHandler()));