English 中文(简体)
如何使用伙伴关系在纯粹的超文本页上填写认证表。 NET?
原标题:How to do Forms Authentication on purely HTML pages using ASP.NET?

我正在使用IIS7的认证表格,通过密码保护一个杰夫网站,但当网站仅包含static RUSfile +login.aspx + web.config时,认证似乎被绕过。

When I renamed the files to .aspx, I am prompted with the login form I am not doing anything fancy. I have a very simple login script and it should just redirect to index.html afterward.

任何建议? 总之,整个网站(现在)使用超文本,需要密码保护。

<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>
问题回答

在IIS7中,如果你想保护*.html或*.htm 档案(或其他非网络延伸)的认证表格,那么在您的网站上添加以下内容:

<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>

尽管这是一个老的问题,但我认为,在普拉多的回答中,这一联系确实有用。 以下是适用于国际空间法研究所7的概述。

在以下网站:web.config, 增加或修改<handlers><system.webServer>:

<handlers>
  <add name="HTML" path="*.html" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv2.0.50727aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
</handlers>

替换<代码>。 代表: 具有正确环境价值。

然后添加或修改<代码><compilation>和<http://Handlers> under <system.web>:

<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>

替换<代码>。 页: 1

你还可以包括按 com子分列的更多延期,





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签