Two MVC projects - Image sharing

送分小仙女□ 提交于 2019-12-13 01:50:25

问题


Here goes:

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.

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?

Thanks!


回答1:


Firstly, is there a reason you have two applications and not a single application with an admin area that is authorised users only?

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




回答2:


I guess, you should merge that to one project and use ASP.NET MVC Areas. Create an Area called "Admin" and keep your admin related stuff inside that. Keep your normal user related stuff in the root level. You should be good then. you should be able to share images between these two as you are in the same project.

If you really want to keep it as seperate project and deploy as seperate websites, you should refer the image in the other website by absolute url of the image



来源:https://stackoverflow.com/questions/10505986/two-mvc-projects-image-sharing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!