加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

Response.Redirect()vs Response.RedirectPermanent()

发布时间:2020-12-16 07:24:30 所属栏目:asp.Net 来源:网络整理
导读:我是ASP.Net 4.0的新手,并且看到了一个名为Response.RedirectPermanent()的新功能.我查了几篇文章,但我无法清楚地了解Response.RedirectPermanent()对Response.Redirect()的实际意义和区别. 根据Gunnar Peipman, Response.Redirect() returns 302 to browser
我是ASP.Net 4.0的新手,并且看到了一个名为Response.RedirectPermanent()的新功能.我查了几篇文章,但我无法清楚地了解Response.RedirectPermanent()对Response.Redirect()的实际意义和区别.

根据Gunnar Peipman,

Response.Redirect() returns 302 to browser meaning that asked resource is temporarily moved to other location. Permanent redirect means that browser gets 301 as response from server. In this case browser doesn’t ask the same resource from old URL anymore – it uses URL given by Location header.

为什么我需要检查服务器响应,例如301,302?它是如何将页面永久重定向到服务器的?

解决方法

301响应(RedirectPermanent)对于SEO目的非常有用.例如,您在ASP.NET WebForms中实现了一个站点,并使用ASP.NET MVC进行了重新设计.您想通知搜索引擎页面/Catalog/ProductName.aspx成为/ products / product-name.然后将301重定向从/Catalog/ProductName.aspx设置为/ products / product-name,搜索引擎索引中的链接将被替换. 302(重定向)主要用于内部目的.例如,登录后重定向(如果在URL中设置了returnUrl).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读