我希望能够请求.html位于~/Views文件夹中的静态文件。根据文档,路由系统在评估应用程序的路由之前会检查URL是否与磁盘文件匹配。但是当我请求文件时出现404错误。我的文件位于〜/ Views文件夹中。网址是:http://[localhost]/Views/HtmlPage1.html我错过了什么?
3 回答

ibeautiful
TA贡献1993条经验 获得超5个赞
要在Views文件夹中允许js和html之类的文件,请在views-Folder中编辑web.config:
<system.webServer>
<handlers>
<add name="JavaScriptHandler" path="*.js" verb="*"
preCondition="integratedMode" type="System.Web.StaticFileHandler" />
<add name="HtmlScriptHandler" path="*.html" verb="*"
preCondition="integratedMode" type="System.Web.StaticFileHandler" />
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
- 3 回答
- 0 关注
- 800 浏览
添加回答
举报
0/150
提交
取消