如何配置ASP.net Forms身份验证否认只是一个特定的网址 [英] How do I configure ASP.net forms authentication to deny only a specific URL

查看:140
本文介绍了如何配置ASP.net Forms身份验证否认只是一个特定的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我有一个admin.aspx页。



一旦用户登录到Admin.aspx页面成功,他们将被重定向到在Report.aspx页面。请注意,Report.aspx页面无法不先成功登录Admin.aspx页面访问。记



请有其他页面一样的Index.aspx等,任何用户都可以不登录查看。我只需要为刚刚Report.aspx页面认证。



我有以下的代码,但似乎并没有工作,因为它说,与虚拟目录的问题。 ?我在做某种根本性错误

 <位置路径=Report.aspx> 
<&的System.Web GT;
<身份验证模式=表格>
<形式loginUrl =的Login.aspx>
<凭证了passwordFormat =清除>
<使用者名称=约翰密码=通行证@ 432/>
< /凭证>
< /形式GT;
< /认证>
<授权>
<拒绝用户=*/>
< /授权>
< /system.web>
< /地点>


解决方案

首先看来你是不是让你的用户约翰。你可能也想尝试拔出配置文件的locaiton特定部分的验证部分:

 <结构> 
<&的System.Web GT;
<身份验证模式=表格>
<形式loginUrl =的Login.aspxdefaultUrl =Report.aspx>
<凭证了passwordFormat =清除>
<使用者名称=约翰密码=通行证@ 432/>
< /凭证>
< /形式GT;
< /认证>
< /system.web>

<位置路径=Report.aspx>
<&的System.Web GT;
<授权>
<让用户=约翰/>
<拒绝用户=*/>
< /授权>
< /system.web>
< /地点>
< /结构>


I have a site where I have a admin.aspx page.

Once the user has logged into the Admin.aspx page successfully, they will then be redirected to the Report.aspx page. Note that the Report.aspx page cannot be accessed without first successfully logging into Admin.aspx page.

Keep in mind that there are other pages like index.aspx, etc which any user can view without logging in. I just need the authentication for JUST the Report.aspx page.

I have the following code but does not seem to work as it says problem with virtual directory. Am I doing something fundamentally wrong?

  <location path="Report.aspx">
    <system.web>
        <authentication mode="Forms">
            <forms loginUrl="Login.aspx" >
                <credentials passwordFormat="Clear">
                    <user name="John" password="pass@432"/>
                </credentials>
            </forms>
        </authentication>
        <authorization>
            <deny users="*" />
        </authorization>
    </system.web>
</location>

解决方案

First it seems you are not allowing your user John. You also might want to try pulling the authentication section of out of the locaiton specific parts of the config file:

<configuration>
  <system.web>
    <authentication mode="Forms">
      <forms loginUrl="Login.aspx" defaultUrl="Report.aspx">
        <credentials passwordFormat="Clear">
          <user name="John" password="pass@432"/>
        </credentials>
      </forms>
    </authentication>
  </system.web>

  <location path="Report.aspx">
    <system.web>
      <authorization>
        <allow users="John"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
</configuration>

这篇关于如何配置ASP.net Forms身份验证否认只是一个特定的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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