ASP.NET 应用程序应在哪里存储数据文件?
我有一个将在共享托管服务上运行的 ASP.NET 页面(例如,我在一台服务器上租用空间,该服务器也为其他人提供内容),并且我需要一种方法来查找可以在其中保存文件的目录,并且不会作为网络内容托管。 该文件将长期存在,并且在会话、访问等之间应该是相同的。我认为 App_data
可能有效。
是否有方法或属性可以为我提供此类目录的绝对路径?
有点像这个问题 没有有用的答案。
I have an ASP.NET page that will run on a shared hosting service (e.i. I'm leasing space on a single server that also serves content for other people) and I need a way to find a directory that I can save files in and that will not get hosted as web content. The file will be long lived and should be the same across sessions, visits, etc. I think App_data
might work.
Is there a method or property that will give me an absolute path to such a directory?
Kinda like this question that doesn't have a useful answerer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
App_Data 是安全的,因为默认情况下您无法通过在浏览器中输入 URL 来从那里下载文件。
如果您需要将用户彼此隔离,则IsolatedStorage 是很好的选择。 在向虚拟目录之外的文件夹授予 NTFS 权限时,IsolatedStorage 需要较少的与 IIS 管理员的协作。 数据库中的 Blob 也是可能的,但是数据库中的 Blob 涉及的额外工作使其成为最后的选择。
App_Data is safe because by default you can't download file from there by typing in a URL to your browser.
IsolatedStorage is good if you need to isolate users from each other. IsolatedStorage requires less collaboration with your IIS admin when it comes to granting NTFS rights to folders outside of your virtual directory. Blobs in the database are possibilities, too but the extra effort involved with blobs in databases makes it a last resort choice.
在 /App_Data/ 中?
in /App_Data/ ?
启动文件服务器。
或者所有 Web 服务器都可以访问的共享目录。
Get a fileserver going.
Or a shared directory that all the web servers can access.
如果数据是静态的 - 您也可以将其存储在资源中。
至少 - 我没有听到任何争论为什么这不好。
If data is static - you can store it in resources too.
At least - i haven't heard any arguments why that is bad.
由于必须在包含这些文件的目录上建立权限,因此通常最好不要将其放在应用程序的路径中。 除此之外,这实际上取决于您可用的资源以及您想要如何管理它。
Due to permissions that must be established on the directory housing these files it is usually for the best that it not be in your application's path. Other than that it really just comes down to what you have available, and how you want to manage it.