Response.Redirect并不总是重定向 [英] Response.Redirect not always redirecting
问题描述
任何想法为什么它会偶尔显示302消息?
深入了解HTTP重定向.aspxrel =nofollow noreferrer>借来的代码应该可以帮助您:
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屋!