拒绝访问文件夹,但允许访问该文件夹中的文件

编程入门 行业动态 更新时间:2024-10-27 08:36:02
本文介绍了拒绝访问文件夹,但允许访问该文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想拒绝匿名用户访问文件夹"test",但排除并允许访问测试文件夹中的文件"webform1".为什么这不起作用?

I would like to deny anonymous users access to the folder 'test' but exclude and allow access to a file 'webform1' inside the test folder. Why does this not work?

<location path="test"> <system.web> <authorization> <deny users="?"/> </authorization> </system.web> </location> <location path="test/webform1"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web>

这是一个示例Webforms项目的链接 github/uselesshasid/StackOverflow_Question_38597397

Here is a link to a sample webforms project github/uselesshasid/StackOverflow_Question_38597397

推荐答案

这可能是asp中的一个错误,它使用友好的url时会处理授权的方式.

This is probably a bug in asp, with the way it handles authorization when friendly url's are used.

我将web.config更改为按文件url的版本进行定义,并且可以正常工作.

I changed the web.config to define by versions of the file url, and it works.

<location path="test/webform1"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> <location path="test/webform1.aspx"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web>

更多推荐

拒绝访问文件夹,但允许访问该文件夹中的文件

本文发布于:2023-10-31 16:46:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546682.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:该文件   文件夹   文件   夹中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!