ASP.NET中的HTML页面的FormsAuthentication

时间:2016-08-31 11:33:16

标签: c# asp.net forms-authentication

想象一下,我们有3个网页,其中两个名称是Main.aspx(默认网址)& Login.aspx(登录网址), 第三个是index.html。 当我想看到index.html它没有登录页面时, 如何使用表单身份验证保护此页面?

如何将.html和其他非.NET扩展添加到有效的扩展列表中以交给.NET引擎?

<authentication mode="Forms">
  <forms defaultUrl="MainPage.aspx" loginUrl="LoginPage.aspx">
  </forms>
</authentication>
<authorization>
  <deny users="?"/>
</authorization>

1 个答案:

答案 0 :(得分:0)

将html页面放在一个文件夹中,并将新的web.config添加到该文件夹​​,并在新创建的web.config设置中拒绝访问匿名用户。

<authorization>
    <deny users="?"/>
</authorization>