本文介绍了拒绝访问文件夹,但允许访问该文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想拒绝匿名用户访问文件夹"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>更多推荐
拒绝访问文件夹,但允许访问该文件夹中的文件
发布评论