Visual Studio 中的 App_Data 文件夹有何用途?
在 Visual Studio 中创建新的 ASP.NET 应用程序时,会自动创建几个文件和文件夹。 其中一个文件夹名为 App_Data
。
此外,通过选择菜单选项构建->发布
来发布网站时,可以使用复选框包含 App_Data 文件夹中的文件
。
我是否正确地假设放入此文件及其子文件夹中的文件将无法通过网络访问? 例如,将我只想由应用程序代码使用的文件夹资源放入其中是否安全?
App_Data
文件夹的真正用途是什么?
编辑:
感谢您的所有回答。 从到目前为止收到的答案来看,我主要对提到的两点感兴趣:
有人能够指定如何“不确保可以通过网络查看”? 在执行标准部署时我是否可以依赖这一事实,或者我是否还需要检查服务器上的某些 IIS 设置。
当我有一组 pdf 文件时,我只想从应用程序中访问它们。 App_Data 文件夹是否是正确的使用位置,或者我应该创建一个单独的文件夹并手动设置 IIS 以确保它无法通过 Web 访问?
When creating a new ASP.NET application in Visual Studio, a couple of files and folders are created automatically. One of those folders is called App_Data
.
Also when publishing a website by selecting the menu option Build->Publish
a checkbox is available Include files from the App_Data folder
.
Am I right assuming that the files put in this file and its sub-folders are not going to be accessible through the web? For example, would it be safe to put in that folder resources that I only intend to be used by the application code?
What is the real intended use of the App_Data
folder?
EDIT:
Thank you for all the answers. From the answers received so far I am interested mostly in two points mentioned:
- App_Data is essentially a storage point for file-based data store
- It should not be viewable by the web and is a place for the web app to store and read data from
Would someone be able specify how the "not viewable by the web" is ensured?
Can I rely on that fact when performing standard deployment, or do I need to check some IIS settings on the server as well.
In the situation when I have a set of pdf files that I want to be accessible only from the application. Would App_Data folder be the right place to use, or should I create a separate folder and manually set IIS to ensure that it is not accessible by Web?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
App_Data 本质上是基于文件的数据存储的存储点(例如,与 SQL Server 数据库存储相反)。 例如,一些简单的站点将其用于存储为 XML 的内容,通常数据库托管费用昂贵。
App_Data is essentially a storage point for file-based data stores (as opposed to a SQL server database store for example). Some simple sites make use of it for content stored as XML for example, typically where hosting charges for a DB are expensive.
在IIS中,突出显示本机,双击“请求过滤”,打开“隐藏段”选项卡。 “App_Data”被列为受限文件夹。 是的,我知道这个线程确实很旧,但这仍然适用。
in IIS, highlight the machine, double-click "Request Filtering", open the "Hidden Segments" tab. "App_Data" is listed there as a restricted folder. Yes i know this thread is really old, but this is still applicable.
App_data 的预期用途是存储应用程序数据以供 Web 进程访问。 它不应该通过网络查看,并且是网络应用程序存储和读取数据的地方。
The intended use of App_data is to store application data for the web process to acess. It should not be viewable by the web and is a place for the web app to store and read data from.
它是放置嵌入式数据库的地方,例如 Sql Server Express、Access 或 SQLite。
It's a place to put an embedded database, such as Sql Server Express, Access, or SQLite.
App_Data文件夹是一个文件夹,您的asp.net工作进程也具有文件系统权限,但不通过Web服务器发布。
例如,我们使用它来更新联系我们表单的本地 CSV。 如果首选的电子邮件方法失败或需要对数据源进行任何查询,则 App_Data 文件就在那里。
这并不理想,但它是一个很好的后备。
The App_Data folder is a folder, which your asp.net worker process has files sytem rights too, but isn't published through the web server.
For example we use it to update a local CSV of a contact us form. If the preferred method of emails fails or any querying of the data source is required, the App_Data files are there.
It's not ideal, but it it's a good fall-back.
来自有关 ASP.NET 的文档MSDN 中的 Web 项目文件夹结构:
From the documentation about ASP.NET Web Project Folder Structure in MSDN:
主要目的是保存应用程序的数据库文件。
默认情况下,这将无法从网络访问。
The main intention is for keeping your application's database file(s) in.
And no this will not be accessable from the web by default.
我们使用它作为上传的 csv 文件的临时存储区域。 上传后,ajax 方法会处理并删除该文件。
We use it as a temporary storage area for uploaded csv files. Once uploaded, an ajax method processes and deletes the file.
App_Data 的预期用途是存储数据库相关文件。 通常是 SQL Server Express .mdf 文件。
The intended use for App_Data is to store database related file. Usually SQL Server Express .mdf files.