C# MVC4URL路由吸收旧的遗留URL并转发到新域

C# MVC4URL路由吸收旧的遗留URL并转发到新域,c#,asp.net-mvc,asp.net-mvc-4,C#,Asp.net Mvc,Asp.net Mvc 4,我的域名曾经指向一个wordpress网站,在那里我使用以下格式设置了特定页面: www.mydomain.com/product/awesome-thing www.mydomain.com/product/another-thing 最近我转移了我的域名,现在它指向了我网站的MVC版本。上面提到的链接不再有效,但是wordpress站点仍然存在,并且具有不同的域。我试图让我的mvc站点吸收以前的链接并将它们转发给 http://mydomain.wordpress.com/product/

我的域名曾经指向一个wordpress网站,在那里我使用以下格式设置了特定页面:

www.mydomain.com/product/awesome-thing
www.mydomain.com/product/another-thing
最近我转移了我的域名,现在它指向了我网站的MVC版本。上面提到的链接不再有效,但是wordpress站点仍然存在,并且具有不同的域。我试图让我的mvc站点吸收以前的链接并将它们转发给

http://mydomain.wordpress.com/product/awesome-thing 
http://mydomain.wordpress.com/product/another-thing
我现在看到的是
RouteConfig.cs

routes.MapRoute(
            name: "product",
            url: "product/{id}",
            defaults: new { controller = "product", action = "redirect", id = UrlParameter.Optional });
在我的产品控制器中,我有以下内容

public void redirect(string id)
{
   if (id == "awesome-thing")
        {
            Response.Redirect("http://mydomain.wordpress.com/product/awesome-thing ");
        }
        if (id == "another-thing")
        {
            Response.Redirect("http://mydomain.wordpress.com/product/another-thing");
        }
        Response.Redirect(" http://mydomain.wordpress.com/");
}

但是,我在
RouteConfig.cs
中的路由未与我的控制器正确连接。我一直收到“404找不到资源”错误。

我通过重新排列地图路线解决了这个问题。我还对控制器和maproute中的代码做了一些更改,下面的代码最终可以正常工作

routes.MapRoute(
          name: "productAwesome",
          url: "product/awesome-thing",
          defaults: new { controller = "product", action = "redirectAwsome" });

routes.MapRoute(
         name: "productAnother",
         url: "product/another-thing",
         defaults: new { controller = "product", action = "redirectAnother" });

//it's important to have the overriding routes before the default definition. 
routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
然后在产品控制器中,我添加了以下内容:

public class productController : Controller
{

    public void redirectAwsome()
    {
        Response.Redirect("http://mydomain.wordpress.com/product/awesome-thing ");
    }
    public void redirectAnother()
    {
        Response.Redirect("http://mydomain.wordpress.com/product/another-thing");
    }
}