大佬教程收集整理的这篇文章主要介绍了asp.net – 拒绝访问web.config中的“admin”文件夹,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图通过web.config拒绝访问我的“管理”文件夹。我查看了另一个类似问题的答案,他们建议使用< LOCATIOn>文件夹,但是当我在路径中插入“Admin /”时,我得到以下错误:
我试过放置“Admin”,“/ Admin”& “管理/”
<configuration> <connectionStrings> <add name="OliverSalonConnectionString1" connectionString="Data source=localhost;Initial Catalog=OliverSalon;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="false" targetFramework="4.0" /> <authentication mode="Forms"> <forms name="Oliver" loginUrl="Login.aspx" path="/" timeout="20"> <credentials passwordFormat="Clear"> <user name="OliverSalon" password="cuts"/> </credentials> </forms> </authentication> <authorization > <deny users="?"/> </authorization> </system.web> <LOCATIOn path="/Admin"> <system.webServer> <directoryBrowse enabled="false"/> </system.webServer> </LOCATIOn>
在您的管理文件夹中放置一个web.config。
内容应为:
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <authorization> <allow roles="admin" /> <deny users ="*" /> </authorization> </system.web> </configuration>
**编辑回答你的问题
如果您设置登录URL,如果未经授权的用户尝试访问您的管理文件夹,框架将自动发送到登录页面。
<authentication mode="Forms"> <forms loginUrl="Login.aspx" timeout="20" slidingExpiration="true" cookieless="AutoDetect" protection="All" requireSSL="false" enableCrossAppRedirects="false" defaultUrl="Default.aspx" path="/"/> </authentication>
以上是大佬教程为你收集整理的asp.net – 拒绝访问web.config中的“admin”文件夹全部内容,希望文章能够帮你解决asp.net – 拒绝访问web.config中的“admin”文件夹所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。