表单身份验证无法正常工作 [英] Form Authentication does not work properly

查看:115
本文介绍了表单身份验证无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我已使用登录控制,在web.config文件中,有以下代码段snipet.

I have one website, i have used login control, in web.config file followig code snipet is there.

<location path="data"></location>
    <system.web>.....


<authentication mode="Forms" >
        <forms defaultUrl="Default.aspx" protection="All" cookieless="UseCookies" name="webaite1" loginUrl="~/login.aspx" path="/"></forms>
      </authentication>
        <compilation debug="false" strict="false" explicit="true" targetFramework="4.0" />
    </system.web>


我有一个文件夹名称数据,其中有一个marks.aspx和一个web.config文件.此web.config文件的代码片段如下:


I have one folder name data, within which i have a marks.aspx and a web.config file. This web.config file has code snipet as follows:

<configuration>
  <location path="data" ></location>
    <system.web>
      <authorization >
        <deny users="five"/>
      </authorization>
    </system.web>
</configuration>


您可以看到用户五被拒绝查看此页面.
问题是,如果有人直接访问此mark.aspx页,则在不让用户登录的情况下访问该页.
我希望如果有人尝试直接访问安全页面,那么他也应该登录,login.aspx应该首先出现.


You can see user five is denied to see this page.
Problem is that if any one is accessing this mark.aspx page directly then page is accessed without letting the user to login.
I want that if some one trying to access secure page directly then also he should login, login.aspx should appears first.

推荐答案

执行以下操作,它将拒绝匿名用户访问该网站
do as below, it will deny anonymous users access to the site
<configuration>
   <system.web>
      <forms defaulturl="Default.aspx" protection="All" cookieless="UseCookies" name="webaite1" loginurl="~/login.aspx" path="/"></forms>
      <authorization>
         <deny users="?" />
      </authorization>
      <compilation debug="false" strict="false" explicit="true" targetframework="4.0" />
   </system.web>
</configuration>


这篇关于表单身份验证无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆