MVC1-5直接访问静态页面

MVC模式下默认是无法访问站点内静态页面,昨日百度找了半天试了半天才试成功。

默认在Views文件外的静态页面可以访问,若要访问Views里的静态页面则需要修改View文件夹中的web.config:

[html] view plain copy 在CODE上查看代码片派生到我的代码片
<httpHandlers>
<add verb="GET,HEAD" path="*.html" type="System.Web.StaticFileHandler"/>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

例如:Views下有一test.html文件,则可以http://localhost:1111/views/test.html如此访问
VS2010.MVC4下测试通过,有问题请在此页面提问。

原文地址:https://www.cnblogs.com/liangxiaofeng/p/5847563.html