两个MVC项目-图像共享 [英] Two MVC projects - Image sharing
问题描述
在这里:
我在解决方案中有2个MVC3项目,其中一个用于管理员,另一个用于普通用户. 管理员在其项目的文件夹中动态上传图像. 因此,我想从User项目中获取这些图像以显示在相同的网页中.
I have 2 MVC3 projects in the solution, where one is for the Admin and the other is for common Users. The Admin dynamically upload images in a folder in his project. So I want to get that images from the User project to show in same web pages.
我还有三个项目,分别代表服务,应用逻辑和数据访问.
I also have three projects that represent the Services, App Logic and the Data Access.
我一直在寻找解决方案,发现了相同的东西: 1-将图像存储在数据库中,然后将其从服务检索到User项目. 2-参考来自用户MVC项目的图像. (无法做到)
I have been looking for a solution and found same things: 1- Store the image in the database and then retrieve it to User project from a service. 2- Reference the image from the User MVC project. (Couldnt do it)
最好的方法是什么? 我该如何实施第一个?
What is the best aproach? How can i implement the first one?
谢谢!
推荐答案
首先,是否有一个原因,您有两个应用程序,而没有一个具有仅授权用户的管理区域的应用程序?
Firstly, is there a reason you have two applications and not a single application with an admin area that is authorised users only?
对于将图像存储在数据库中,您可以将图像转换为字节数组,并将其作为varbinary(max)存储在数据库中.
As for storing the image in the database you can convert the image to a byte array and store it as varbinary(max) in your database.
此问题显示了一个将文件流(我假设您正在通过表单上传图像)转换为字节数组的示例:
This question shows an example of converting the file stream (I assume you are uploading the image through a form) to a byte array: Convert a bitmap into a byte array
这篇关于两个MVC项目-图像共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!