Copied to clipboard

Flag this post as spam?

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


  • Niels Henriksen 73 posts 276 karma points
    Oct 09, 2018 @ 06:49
    Niels Henriksen
    0

    301 redirect of asp.old pages

    I am working on a website that is made in asp.old and there is a lot of pages (categories [category.asp?id=xx] and products [product.asp?id=yy]) and now I am not sure where it will be best to implement 301 redirect.

    I am using ContentFinder to show the right category and product when reading the url and I can get the ContentFinder to fire when getting the asp.old page. But can I implement the 301 redirect in the ContentFinder class? Or do I need to do it in web.config?

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    Oct 09, 2018 @ 10:56
    Marc Goodson
    101

    Hi Niels

    You can implement the redirect in the content finder.

    The PublishedContentRequest has a SetRedirectPermanent method:'

     public class PermanentRedirectFinder : IContentFinder
        {
            public bool TryFindContent(PublishedContentRequest contentRequest)
            {
    // is it an old url that needs redirecting?
    // determine new url
    string newUrl = "/whatever/it/should/be";
     contentRequest.SetRedirectPermanent(newUrl);
                    return true;
    }
    }
    
  • Niels Henriksen 73 posts 276 karma points
    Oct 09, 2018 @ 11:04
    Niels Henriksen
    0

    That is so perfect :) Nice

Please Sign in or register to post replies

Write your reply to:

Draft