Learn More





Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesCustom URL Routing issue with DNNCustom URL Routing issue with DNN
New Post
11/9/2013 4:40 AM


We are developing a custom module for DNN 7 which generate some URLs

where MyPage.aspx page is a page created on DNN which contains our working module and when the above URL is called it works fine.

We now wanted to make this SEO friendly and wanted to write our custom logic and URL routing.

eg: to route to the above page.

We added the following lines in the web.config page:


<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

and the following code in Global.asax file:

<%@ Application Inherits="DotNetNuke.Web.Common.Internal.DotNetNukeHttpApplication" Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Web.Compilation" %>
<script runat="server">
    public class myPageCategoryRouteHandler : IRouteHandler
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
            string categoryName = requestContext.RouteData.Values["Category"] as string;
            string productName = requestContext.RouteData.Values["Product"] as string;
            if (string.IsNullOrEmpty(categoryName))
                HttpContext.Current.Items["Category"] = "defaultCategory";
                return BuildManager.CreateInstanceFromVirtualPath("/myPage.aspx", typeof(Page)) as Page;
                HttpContext.Current.Items["Category"] = categoryName;
                if (!String.IsNullOrEmpty(productName))
                    HttpContext.Current.Items["Product"] = productName;
                    return BuildManager.CreateInstanceFromVirtualPath("/myPage.aspx", typeof(Page)) as Page;
                return BuildManager.CreateInstanceFromVirtualPath("/myPage.aspx", typeof(Page)) as Page;
    void Application_Start(object sender, EventArgs e)
    void RegisterRoutes(RouteCollection routes)
        routes.Add("Credit Cards Products",new Route("myPage/{Category}/{Product}", new myPageCategoryRouteHandler()));
        routes.Add("Credit Cards",new Route("myPage/{Category}", new myPageCategoryRouteHandler()));
    void Application_End(object sender, EventArgs e)
        //  Code that runs on application shutdown
    void Application_Error(object sender, EventArgs e)
        // Code that runs when an unhandled error occurs
    void Session_Start(object sender, EventArgs e)
        // Code that runs when a new session is started
    void Session_End(object sender, EventArgs e)
        // Code that runs when a session ends.
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer
        // or SQLServer, the event is not raised.

But Whatever we do we get a 404 file not found error.
it cannot be the hosting server because I created a blank site on the server with a test domain and set the similar URL routing with the global.asax and web.config, basically a simple website, and the URL routing worked flawlessly. so I figured the problem has to be with DNN.

Can anyone point out what we are doing wrong? Do we have to do routing in a different way in DNN? any help would be really great.


New Post
11/9/2013 12:11 PM


First of all if you urls are it meen you dont use the rigth way to generate urls in dnn.

You have to use Globals.NavigateUrl(...) for generating urls (or EditUrl).

Ones you have done this, you have to create a url rewriter provider for your module to extend the url rewriter with your rules.

For DNN 7.1.x you can find more info :

An alternative is to use OpenUrlRewriter

and here info to create your custom provider for your module 

(Little bit easyer to implement, i think.)


New Post
11/11/2013 12:19 AM

Thanks Sacha,

I knew there was something specific with DNN when it came to routing. I shall follow your recommendations and see if it works. I shall update once I'm through.


HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesCustom URL Routing issue with DNNCustom URL Routing issue with DNN

These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?