Response.Redirect并不总是重定向 [英] Response.Redirect not always redirecting

查看:399
本文介绍了Response.Redirect并不总是重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在一个工作不稳定的页面上有一个简单的Response.Redirect(IIS 6.0)。大多数情况下,它的重定向都是正确的,但是我们得到一些用户抱怨说不是重定向,而是把302对象移到这里页面。该页面显示正确位置的标题信息。如果你点击这里,它会重定向到正确的页面。



任何想法为什么它会偶尔显示302消息?

解决方案

借来的代码应该可以帮助您:

  Response.StatusCode = 301; 
Response.StatusDescription =永久移动;
Response.RedirectLocation =RedirectionPage.aspx;
Response.Flush();

您也可以使用Server.Transfer()或者输出一个简单的脚本将窗口的位置设置为新的URL。

  Page.ClientScript.RegisterStartupScript(Page.GetType 
RedirectScript, window.location.href ='RedirectionPage.aspx',true);

虽然我不知道他们的浏览器如何处理javascript,



您有关于这些人正在使用的浏览器的任何信息吗?


We have a simple Response.Redirect on a page that is working inconsistently (IIS 6.0). Most of the time it redirects correctly, but we're getting some users that are complaining that instead of redirecting, they are getting the "302 Object moved to here" page. The page displays the header information with the correct location. If you click "here," it redirects to the correct page.

Any ideas why it would display the 302 message sporadically?

解决方案

You could try to manually set the status code of the response to 301. Here is some borrowed code that should help you out:

Response.StatusCode = 301; 
Response.StatusDescription = "Moved Permanently";
Response.RedirectLocation = "RedirectionPage.aspx";
Response.Flush();

You could also use as a last-ditch effort Server.Transfer() or output a simple script that sets the window's location to the new url.

Page.ClientScript.RegisterStartupScript(Page.GetType
"RedirectScript", "window.location.href='RedirectionPage.aspx'", true);

Although I wonder how well their browsers will do with javascript if they're not respecting the original redirection.

Do you have any information on the browsers these people are using?

这篇关于Response.Redirect并不总是重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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