IIS7表单身份验证不会拒绝图像访问
我在IIS7中建立了一个基本的ASP.NET网站,并在服务器上启用了表单身份验证.只是出于笑容,我否认所有人:
I have a basic ASP.NET website set up in IIS7 with forms authentication enabled on the server. Just for grins, I deny everyone:
<?xml version="1.0"?>
<configuration>
<system.web>
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="Login.aspx" defaultUrl="Test.aspx" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true"/>
</authentication>
<authorization>
<deny users="*"/>
</authorization>
<compilation debug="true"/>
</system.web>
</configuration>
当我访问default.aspx页面时,我忠实地重定向到Login.aspx页面.但是,我可以浏览到同一站点根目录下的.txt文件或.png文件,并且可以毫无挑战地显示它.
When I visit the default.aspx page, I get dutifully redirected to the Login.aspx page. However, I can browse to a .txt file or .png file on the root of the same site, and it displays it with no challenge.
这很奇怪,因为在Cassini开发服务器中,对这些文件的访问被阻止.仅当我发布到IIS7服务器时才会发生这种情况.
This is odd, because in the Cassini dev server, access to those files is blocked. This only occurs once I publish to my IIS7 server.
我肯定在IIS7中缺少某些东西,但是我一生都无法解决.
I must be missing something in IIS7, but I can't figure it out for the life of me.
- 我在启用集成模式的.NET 4.0应用程序池中拥有该网站.
- 在服务器上启用了表单身份验证
- 在FormsAuthentication模块的编辑托管模块"弹出窗口上,我尝试取消选中仅为请求调用...",但是这样做时会抛出某种奇怪的错误(缺少某种形式的组合件?这是一个全新的服务器安装,没有多余的装饰,所以我无法想象这是怎么回事.
有人可以为此指出正确的方向吗?
Can anyone point me in the right direction on this?
谢谢! 刺绣
首先,您必须使用集成管道,然后将其添加到web.config中:
first of all you have to use integrated pipeline and then add this in your web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="false">
<remove name="FormsAuthenticationModule" />
<add name="FormsAuthenticationModule" type="System.Web.Security.FormsAuthenticationModule" />
<remove name="UrlAuthorization" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
</modules>
</system.webServer>