这是我的 web.config 文件。此配置拒绝所有用户访问 pdf 文件,但我想添加一个例外,其中 ASP.NET 页面可以访问 PDF 文件。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
<caching>
<profiles>
<add extension=".css" policy="DisableCache" kernelCachePolicy="DisableCache" />
<add extension=".inc" policy="DisableCache" kernelCachePolicy="DisableCache" />
<add extension=".html" policy="DisableCache" kernelCachePolicy="DisableCache" />
<add extension=".asp" policy="DisableCache" kernelCachePolicy="DisableCache" duration="00:00:30" />
</profiles>
</caching>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="pdf" path="*.pdf" verb="*" type="System.Web.HttpForbiddenHandler" resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
<system.web>
<authentication mode="Windows" />
<authorization>
<allow users="test" />
</authorization>
</system.web>
</configuration>
例如,aviewpdf.aspx
可以访问/加载所有 pdf 文件。
我可以在 web.config 中创建一个可以执行此操作的异常吗?