ASP.NET - 301重定向 [英] ASP.NET - redirect 301
本文介绍了ASP.NET - 301重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在ASP点网永久重定向?我想从一个网页做301重定向在我的网站到另一个页面。
解决方案
保护无效Page_ preINIT(对象发件人,EventArgs的发送)
{
Response.Status code = 301;
Response.StatusDescription =感动永久;
Response.RedirectLocation =AnotherPage.aspx;
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
而在4.0中,有一个简单的<一个href=\"http://msdn.microsoft.com/en-us/library/dd384856.aspx\"><$c$c>Htt$p$psponse.RedirectPermanent()$c$c>方法不高于一切为您:
的Response.RedirectPermanent(AnotherPage.aspx);
How do I redirect permanently in ASP DOT NET? I'd like to do a 301 redirect from one page on my site to another page.
解决方案
protected void Page_PreInit(object sender, EventArgs e)
{
Response.StatusCode = 301;
Response.StatusDescription = "Moved Permanently";
Response.RedirectLocation = "AnotherPage.aspx";
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
And in 4.0, there's a simple HttpResponse.RedirectPermanent()
method that does everything above for you:
Response.RedirectPermanent("AnotherPage.aspx");
这篇关于ASP.NET - 301重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文