Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Patrick Scott 70 posts 110 karma points c-trib
    Oct 30, 2014 @ 20:21
    Patrick Scott
    0

    Programatically creating UrlRewritingNet Rules

    I am trying to create some URLRewriting rules in the ApplicationStarted event handler,  but they don't seem to be added to httpHandlers collection.

    I can't do this in the URLRewriting.config file as I need to get some info from the content nodes. The code I am using is:

    rule = new UrlRewritingNet.Web.RegExRewriteRule();
    rule.VirtualUrl = "^~/blog/page/(.*)";
    rule.RewriteUrlParameter = UrlRewritingNet.Web.RewriteUrlParameterOption.ExcludeFromClientQueryString;
    rule.DestinationUrl = "~/blog?p=$1";
    rule.IgnoreCase = true;
    UrlRewritingNet.Web.UrlRewriting.AddRewriteRule(Articulate_Paging", rule);
    

     

    When I check the rewriting collection at UrlRewritingNet.Web.UrlRewriting.Configuration.Rewrites the new rule has not been added. 
    Is anyone else adding rewrite rules programtically? Do I have to add them during a specific event?

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies