2012-10-17 42 views
3

我有一個網站在Windows 2003的IIS6和XP中的開發環境上運行。一切正常。與IIS7的ASP.NET response.redirect

我已經被迫在Windows 7

創建一個新的發展環境,因爲用這個,我發現Reponse.Redirect不再工作......在某些情況下!

我有以下代碼:

Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID));

它工作正常,在IIS6。

它也適用於IIS7.5上大多數站點。但是在一些頁面中,事實並非如此。

我已經看過返回的頭文件,並且可以看到請求頭文件中有一個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" /> 

(都有結束標記)

但這沒有幫助。

任何人都可以想到任何嘗試讓這些工作?

回答

0

你試過

Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID), false); 
0

這不是完美的解決方案,但解決方法 - 從頁面

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來讓你頁面重定向。 您可以在普通工具類中移動上述方法。