2012-09-24 109 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) –