我怎么能发送301永久重定向与ASP.NET? [英] How can I send a 301 Permanent Redirect with ASP.NET?

查看:107
本文介绍了我怎么能发送301永久重定向与ASP.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要永久重定向某些网页,并将用户重定向到新的URL为好。

这code只设置正确的头。用户不被重定向。

 公共静态无效PermanentRedirect(这Htt的presponse响应,串NEWURL)
{
  response.Status =301永久移动;
  response.Status code = 301;
  response.AddHeader(位置,NEWURL);
}

如果我把:

 的Response.Redirect(NEWURL);

在年底,302临时重定向执行。

我怎样才能301重定向用户?


  

相关问题:


  
  

<一个href=\"http://stackoverflow.com/questions/868851/how-do-i-programatically-301-redirect-in-an-asp-page\">How我编程301重定向在ASP页面



解决方案

尝试Response.Flush和到Response.End。重定向说,通过发送302结束请求。

I need to permanent redirect some pages, and redirect the user to the new URL as well.

This code only sets the correct headers. The user are not redirected.

public static void PermanentRedirect(this HttpResponse response, string newUrl)
{
  response.Status = "301 Moved Permanently";
  response.StatusCode = 301;
  response.AddHeader("Location", newUrl);
}

If I put:

Response.Redirect(newUrl);

at the end, a 302 Temporary Redirect is performed.

How can I 301 redirect the user?

Related Questions:

How do I programatically 301 redirect in an asp page

解决方案

Try Response.Flush and Response.End. Redirect says to end the request by sending a 302.

这篇关于我怎么能发送301永久重定向与ASP.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆