加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

检测asp.net将用户重定向到登录页面

发布时间:2020-12-16 09:44:26 所属栏目:asp.Net 来源:网络整理
导读:我的网站上有一个受匿名用户保护的目录.我的web.config看起来像这样 location path="members" system.web authorization allow roles="members" / deny users="*" / /authorization /system.web/location 如果匿名用户尝试访问“/ members”目录中的页面,他
我的网站上有一个受匿名用户保护的目录.我的web.config看起来像这样

<location path="members">
    <system.web>
        <authorization>
            <allow roles="members" />
            <deny users="*" />
        </authorization>
    </system.web>
</location>

如果匿名用户尝试访问“/ members”目录中的页面,他们将被重定向到登录页面.

从登录页面上的代码隐藏,有没有办法告诉用户重定向这种方式与用户手动进入登录页面之间的区别? (通过输入网址或点击登录页面的链接)

我知道网络是无国籍的,所以也许这两个请求难以区分

如果无法区分这两者,是否有办法拦截之前发生的事情.net因为未经授权的访问尝试而决定重定向用户?

注意:我不能在查询字符串中使用“ReturnUrl”,因为我将以相同的方式装饰它

解决方法

您可以查看“推荐人” request header

The Referer[sic] request-header field allows the client to specify,for the server’s benefit,the address (URI) of the resource from which the Request-URI was obtained (the “referrer”,although the header field is misspelled.)

但浏览器可以欺骗引用者.另请参阅this article,它提供了一些有关未授权访问的示例,它完整地描述了asp.net授权的工作原理.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读