你如何要求在ASP.NET MVC的〜/ Views文件夹下的静态HTML文件? [英] How do you request static .html files under the ~/Views folder in ASP.NET MVC?
问题描述
我希望能够要求它位于〜/浏览次数
文件夹的静态的.html
文件。
根据该文件,看看路由系统检查,如果一个URL评估应用程序的途径之前,磁盘文件相匹配。
但是,当我要求 404
错误发生的文件。
我的文件位于〜/ Views文件夹。
网址是:的http:// [本地主机] /Views/HtmlPage1.html
什么我错过了?
我希望能够要求它位于〜/视图文件夹中的静态HTML文件。
块引用>您不能。有此文件夹其中明确禁止从它访问任何文件Web.config文件中。如果您希望能够从客户端这些文件不应该放在
查看其中有在ASP.NET MVC中有特殊的意义
文件夹访问文件。您可以有一个
〜/静态
文件夹,在那里你可以把你的HTML文件。然后访问它这样:http://example.com/yourapplicationname/static/foo.html
I want to be able to request static
.html
files which are located in the~/Views
folder. According to the documentation, the routing system checks to see if a URL matches a disk file before evaluating the application's routes.But when I request the file a
404
error arises.My file is located in ~/Views folder. The URL is:
http://[localhost]/Views/HtmlPage1.html
What have I missed?
解决方案I want to be able to request static .html files which are located in the '~/Views' folder.
You can't. There's a web.config file in this folder which explicitly forbids accessing any file from it. If you want to be able to access files from the client those files should not be placed in the
Views
folder which has a special meaning in ASP.NET MVC.You could have a
~/Static
folder where you could place your HTML files. And then access it like that:http://example.com/yourapplicationname/static/foo.html
这篇关于你如何要求在ASP.NET MVC的〜/ Views文件夹下的静态HTML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!