我在IIS7中使用表单身份验证来对开发站点进行密码保护,但是当站点只包含static HTML文件+ login.aspx + web.config时,身份验证似乎被绕过了。
当我将这些文件重命名为.aspx时,系统会提示我登录表单I‘m not花哨。我有一个非常简单的登录脚本,它应该只是重定向到index.html之后。
有什么建议吗?总而言之,整个站点都在使用HTML (目前),需要密码保护。
<authentication mode="Forms">
<forms name="appNameAuth" path="/" loginUrl="~/login.aspx" defaultUrl="index.html" protection="All" timeout="525600">
<credentials passwordFormat="Clear">
<user name="[user]" password="[password]" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
发布于 2010-08-28 13:25:59
你可以在ASP.NET中通过关联你需要的扩展名(例如:.html、.htm等)和aspnet_isapi.dll。
一旦ASP.NET为这些文件提供服务,您就可以像任何aspx页面一样为它们指定权限。
有关更多信息,请参阅MSDN
默认情况下,
本身处理静态内容,并且仅在请求扩展名为.aspx、.asmx或.ashx的页面时将请求传递给ASP.NET运行时。
但是,IIS7允许集成IIS和ASP.NET管道。只需几个配置设置,您就可以设置IIS7为所有请求调用FormsAuthenticationModule。此外,使用IIS 7,您可以为任何类型的文件定义URL授权规则。有关更多信息,请参阅IIS6和IIS7安全性之间的更改、您的IIS7平台安全性和了解Web授权。
长话短说,在IIS7之前的版本中,只能使用表单身份验证来保护由ASP.NET运行时处理的资源。同样,URL授权规则仅应用于由ASP.NET运行时处理的资源。但是使用IIS7可以将FormsAuthenticationModule和UrlAuthorizationModule集成到IIS管道中,从而将此功能扩展到所有请求。
发布于 2010-10-25 01:06:07
在IIS7中,如果要在forms身份验证下保护*.html或*.htm文件(或其他非.net扩展名),则将以下行添加到web.config中:
<compilation>
<buildProviders>
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
<add extension=".htm" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>
和
<system.webServer>
<handlers>
<add name="HTML" path="*.html" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" />
<add name="HTM" path="*.htm" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
发布于 2016-05-11 16:19:29
虽然这是一个古老的问题,但我发现pomarc答案中的链接真的很有用。以下是适用于IIS7的摘要。
在web.config
中,在<system.webServer>
下添加或修改<handlers>
<handlers>
<add name="HTML" path="*.html" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
</handlers>
将verb
值替换为所需的值;将scriptProcessor
值替换为您的环境的正确路径。
然后,在<system.web>
下添加或修改<compilation>
和<httpHandlers>
<compilation debug="false" strict="false" explicit="true">
<buildProviders>
<!--Add below so .html file will be handled by ASP.NET (for use of Forms Authentication)-->
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>
<httpHandlers>
<!--Add below so .html file will be handled by ASP.NET (for use of Forms Authentication)-->
<add verb="GET, HEAD, POST, DEBUG" path="*.html" type="System.Web.UI.PageHandlerFactory" />
</httpHandlers>
将verb
值替换为所需的值。
您还可以包含更多的扩展名,用逗号',‘分隔
https://stackoverflow.com/questions/3589020
复制相似问题