{ Dev Farm }

Web & Windows Development

Correct Link SEO Migration from old Asp.Net WebForm to new Asp.Net Mvc Website

| 0 commenti

When you are designing a new website you have to think about old website links migration.

This is very important to avoid tons of 404 errors and losing massive traffic.

First of all you’ll have to find out all your old link. Such as

/news/Default.aspx
/news/Default.aspx?id=123
/news/Default.aspx?id=456
etc..

and map them to

/news/
/news/new-website
/news/dismiss-old-website
etc..

Fortunately ASP.NET MVC made this translation quite simple.

In your global.asax (or RegisterRutes function) add the code to handle the 301 redirect

    routes.MapRoute(
        name: "News Redirect",
        url: "news/Default.aspx",
        defaults: new { controller = "Redirect", action = "News" }
    );

Than, I suppose you have a Redirect Controller, just convert the old link in the new website url system.

    public class RedirectController : Controller
    {

        public ActionResult News(int? id)
        {
            if (id > 0)
            {
                // your code to find out your new permalink
                var permalink = "xxxxxxxxxxxxxxxxxxxx";
                // your code to find out your new permalink
                return RedirectPermanent("/News/" + permalink);
            }
            return RedirectPermanent("/News");
        }

    }

RedirectPermanent function will set301 as Response Status Code.
Http Status Code 301 means “Moved Permanently”, in this way the search engine will replace the old link with the new one without losing traffic and throwing annoying 404 errors.

Other Resources:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

http://msdn.microsoft.com/it-it/library/system.web.httpresponse.redirectpermanent.aspx

Lascia un commento

I campi obbligatori sono contrassegnati con *.