开发者

asp.net mvc 2.0 - 301 permanent direct

开发者 https://www.devze.com 2023-03-02 10:03 出处:网络
I\'ve seen a few similar questions to mine but not exactly what I\'m after. this question shows me how to do the r开发者_如何学Pythonedirect but where/how do I put the extra information in the redire

I've seen a few similar questions to mine but not exactly what I'm after.

this question shows me how to do the r开发者_如何学Pythonedirect but where/how do I put the extra information in the redirect to tell the search engines that it is a 301?

ASP.Net MVC - Trapping certain URL's to do 301 Redirect


You could try something like this:

public ActionResult Home() {
    Response.Status = "301 Moved Permanently";
    Response.RedirectLocation = "/";
    Response.End();
    return Redirect("~/");
}

This works for one off. If you have multiples, then you'll want to come up with some sort of handler.

One such handler I've used is Legacy Routing. It worked out quite well for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消