【发布时间】:2018-06-25 16:26:27
【问题描述】:
出于安全原因,我想通过应用程序级别禁用一些 http 方法(例如 OPTIONS、TRACE、HEAD)。我想对目录“bundles/”中的所有文件执行此操作
但是这个路径其实是由这个创建的
bundles.Add(new Bundle("~/bundles/Something").Include("~/Contents/Scripts/file.js"));
bundles.Add(new Bundle("~/bundles/Anything").Include("~/Areas/Import/Scripts/App/anotherfile.js"));
现在我尝试了这个(在 Web.config 中)
<system.web>
<httpHandlers>
<add path="bundles/" verb="OPTIONS,TRACE,HEAD" type="System.Web.HttpMethodNotAllowedHandler" />
</httpHandlers>
</system.web>
但它不起作用
所以,我希望用户在对 myapp.com/bundles/example
等任何链接发出 OPTIONS、TRACE、HEAD 请求时获得 405 Method Not Allowed谢谢
【问题讨论】:
标签: asp.net asp.net-mvc web-config http-method