我应该使用我的配置文件(sql 配置文件提供程序)存储图像吗?

发布于 2024-08-03 10:33:29 字数 372 浏览 2 评论 0原文

我正在 asp.net 中开发一个 Intranet Web 应用程序,它需要存储用户个人资料图像。

@edit:Web应用程序应该同时在两个不同的Web服务器中运行。

我的问题是,最好的方法是什么?使用配置文件保存照片(我正在使用 SqlProfileProvider)还是将其上传到文件系统并仅将链接保存在配置文件中?

我了解一种操作与另一种操作的性能差异,但我的 Intranet 将由数百个用户使用,我非常喜欢将所有数据存储到一个位置(例如,使备份数据更容易)。

假设我将数据存储到数据库中,还有另外两个问题:

a)我应该使用什么类型来保存照片?字节[]???

b)我应该创建一个处理程序来显示图像,还是有更简单的方法?

I'm developing an intranet webapp in asp.net that has a requirement for storing user profile images.

@edit: The webapp should be running in two different web servers at the same time.

My question is, what would be the best approach? Saving the photo with the profile (I'm using the SqlProfileProvider) or upload it to the file system and just save the link in the profile?

I understand the performance difference from one operation to the other, but my intranet would be used by a few hundred users and I very much like to store all data into a single place (makes backing up data easier for instance).

Assuming data I would store into the database, there are two other questions:

a) what type should I use for saving the photos? byte[]???

b) should I create a handler to display the image, or is there an easier approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

杀お生予夺 2024-08-10 10:33:29

考虑数据库存储的唯一原因是在网络场场景中。如果您只有一台 Web 服务器,那么使用文件系统并将图像路径存储在配置文件中会更快更容易。

The only reason to think about DB storage would be in a web farm scenario. If you just have one web server it is much faster and easier to use the file system and just store the image path in the profile.

千里故人稀 2024-08-10 10:33:29

我目前正在数据库中使用图像字段来存储图像,但是,请查看 此文档,我想我应该转向 VarBinary。

然后,我使用 HttpHandler 根据请求提供图像(尽管我的网站的最新版本在图像控制器上也有一个 MVC 文件操作处理程序,可以执行相同的操作)。

我的处理程序的一个例子可以在这个答案中看到:

如何知道已请求哪个图像。

I'm currently using an Image field in my database to store images, however, looking at the warning attached to this documentation, I guess I should move to a VarBinary.

I'm then using an HttpHandler to serve the images as requested (although the latest version of my site also has an MVC file action handler on the images Controller that does the same thing).

An example of my handler can be seen in this answer:

How to know which Image has been requested.

瞳孔里扚悲伤 2024-08-10 10:33:29

无论如何,备份应该包括您的网站文件夹,因此我认为不使用文件系统和 IIS 来实现其目的(存储和提供文件)没有明显的优势。

为什么要费尽心思抽象一个文件系统,包括 IIS 和 MSSQL 之间的所有线路流量、代码开销等,只是为了避免备份文件夹?

Backups should include your web site folders anyway, so I see no clear advantage to not using the file system and IIS for what it is intended to do--store and serve files.

Why go through the trouble of abstracting a file system, complete with all the wire traffic between IIS and MSSQL, code overhead, etc. just to avoid backing up a folder?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文