2012-09-24 72 views
3

我們有一個從3.5升級的ASP.NET 4.0 Web應用程序。不幸的是,當用戶試圖通過http://xxx.abc.com/訪問URL時,用戶獲取/login.aspx?ReturnUrl=%2f。IIS 7 ASP.NET 4.0忽略默認文檔

我明白,這似乎是在.NET 4.0和IIS7行爲。這會導致負載平衡器出現問題,因爲它會返回302狀態代碼。某些原因 負載平衡器已配置爲查找http 200狀態代碼。

有什麼辦法可以解決這個ASP.NET 4.0的行爲,這樣,當用戶點擊http://xxx.abc.com/,表明不進行重新定向的login.aspx的?

我想這下面,但沒有工作:

<system.webServer> 
    <defaultDocument> 
     <files> 
     <add value="Login.aspx" /> 
     </files> 
    </defaultDocument> 
</system.webServer> 

感謝。

回答

3

這不是.NET 4/IIS 7的行爲,這是形式的認證行爲。看起來認證模塊首先運行,並在默認文檔模塊得到機會之前觸發重定向。下面是我建議的解決辦法:

  • <allow users="?" />在您的網站的根目錄使用location標籤。
  • 如果上述不可行或不實際,請使用URL Rewrite module而不是依靠默認文檔。

我用這個重寫規則獲得login.aspx從根URL返回200個狀態碼:

<rewrite> 
    <rules> 
    <rule name="RewriteURL1" stopProcessing="true"> 
     <match url="" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="login.aspx" /> 
    </rule> 
    </rules> 
</rewrite> 
+1

使用<匹配URL = 「^ $」/>匹配空URL(如域只URL) –