Search code examples
asp.netkentico

Custom Routes with kentico Portal Template


Asp.net allows us to register new custom routes

http://www.example.com/products.aspx?category=software

to call them like that : http://www.example.com/products/software

 void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);

    }
 static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapPageRoute("testroute", "Test/{parame}", "~/Default.aspx");
    }

This method works in Kentico but only for .aspx pages (for example for pages in ~/CMSPages/Default.aspx). My question is how to achive same results for pages created with Portal Template approach? I was trying to make my own HttpHandler

public class CustomHandlerProduct : IHttpHandler
{
    public CustomHandlerProduct()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public bool IsReusable
    {
        // To enable pooling, return true here.
        // This keeps the handler in memory.
        get { return false; }
    }

    public void ProcessRequest(HttpContext context)
    {
    }
}

or even HttpModule according to this article link to CodeProject article

but i can not achive desired results

any Ideas?


Solution

  • If you want to use Portal engine, is there a reason not to use Kentico URL rewriting capabilities? Wildcard URLs work very similarly to routes. See the documentation https://docs.kentico.com/display/K82/Wildcard+URLs