[英]ASP.NET response.redirect with IIS7
我有一個在Windows 2003中的IIS6上運行的站點,以及XP中的開發環境。 一切正常。
我被迫在Windows 7中創建一個新的開發環境。
自從使用它以來,我發現Reponse.Redirect在某些情況下不再有效!
我有以下代碼:
Response.Redirect(Globals.NavigateURL( PortalSettings.ActiveTab.TabID ));
它在IIS6上運行正常。
它也適用於IIS7.5上的大多數站點。 但是在某些頁面中,並非如此。
我查看了返回的標頭,並且可以看到Request標頭中有一個GET響應,這對於它應該重定向的正確頁面也是如此,但事實並非如此!
按鈕周圍有一個RadAjaxPanel用於觸發此重定向,但在父控件中。 不工作的按鈕位於單獨的ascx控件中。
我在其他類似帖子中找到的Web.Config中有以下內容:
<system.webServer>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
和
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
(都有結束標簽)
但這沒有幫助。
任何人都可以考慮嘗試讓這些工作嗎?
你有沒有嘗試過
Response.Redirect(Globals.NavigateURL( PortalSettings.ActiveTab.TabID ), false);
這不是完美的解決方案,而是一種解決方法 -
private void Redirect(string url)
{
// Define the name and type of the client script on the page.
String csName = "RedirectScript";
Type csType = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the client script is already registered.
if (!cs.IsClientScriptBlockRegistered(csType, csName))
{
StringBuilder csText = new StringBuilder();
csText.Append("<script type=\"text/javascript\"> ");
csText.Append("window.location.href = {0} </", url);
csText.Append("script>");
cs.RegisterClientScriptBlock(csType, csName, csText.ToString());
}
}
從頁面調用 -
Redirect(Globals.NavigateURL( PortalSettings.ActiveTab.TabID ));
這將使用JavaScript讓您的頁面重定向。 您可以在公共實用程序類中移動上述方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.