简体   繁体   English

在同一解决方案中将一个项目的照片文件用于另一个项目

[英]Use photo file from one project to another project in the same solution

i have solution where are three project (Intr.net, Site, and Data).我有解决方案,其中三个项目(Intr.net、站点和数据)。 In Intr.net i have form where I add new Restaurant object (name, description, photo and etc.).在 Intr.net 中,我有添加新餐厅 object(名称、描述、照片等)的表格。 Photos are saved in Path Intr.net/wwwroot/images/items and link to the photo is saved in database like this:照片保存在路径 Intr.net/wwwroot/images/items 中,照片链接保存在数据库中,如下所示:

wwwroot\\images\\items\\<photo_name>

When i want display photo in this same project i use:当我想在同一个项目中显示照片时,我使用:

<img class="img-responsive" src="@Url.Content("~/images/items/" + @item.Photo2)" alt="">

But if i want display this photo in other project (Site), it doesn't work, since they are in other project.但是如果我想在其他项目(站点)中显示这张照片,它不起作用,因为它们在其他项目中。 It is possible change src in Site Project to display photos from another project?可以更改 Site Project 中的 src 以显示来自另一个项目的照片吗? Or is better way to do this?或者是更好的方法来做到这一点?

One of the solutions might be to use a virtual folder that points to the right physical folder of the source project.解决方案之一可能是使用指向源项目的正确物理文件夹的虚拟文件夹。 This folder will act as own folder of the Site project and you can point to its content in a similar way as you do in the Intr.net .此文件夹将充当站点项目的自己的文件夹,您可以像在Intr.net中那样以类似的方式指向其内容。

ie if Intr.net path for images is即如果图像的Intr.net路径是

C:\inetpub\wwwroot\images\items 
                          ^^^^^

create a new virtual directory /items under /images of Site project in IIS and point to the same source directory of your other project在IIS的Site项目/images下新建一个虚拟目录/items ,并指向你其他项目的同源目录

C:\inetpub\wwwroot\images\items 

This will let you to access same images as ~/images/items/ in the Site project.这将允许您访问与站点项目中的~/images/items/相同的图像。

Another approach would be to create an image handler that will programmatically access required file and output it to the browser as an image.另一种方法是创建一个图像处理程序,该处理程序将以编程方式访问所需的文件并将其作为图像 output 发送到浏览器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在同一解决方案中使用从一个项目到另一个项目的依赖关系 - Use dependency from one project to another in the same solution 在同一解决方案中使用另一个项目的引用 - Use reference from another project at the same solution 一个项目的class在同一个方案下如何在另一个项目中使用? - How to use a class of one project in another project under the same solution? 在同一解决方案中从另一个项目中的一个项目打开xaml页面 - Open a xaml page from one project in another project in the same solution 将服务引用从一个项目复制到同一解决方案中的另一个项目 - Copy service reference from one project to another project in same solution 将用户控件从一个项目复制到同一解决方案中的另一个项目 - Copy User Control from one project to another within same solution 如何在同一个解决方案中将一个项目的功能包含到另一个项目中? - How to include functionality from one project into another in the same solution? 如何访问上传到同一解决方案中另一个项目的照片 - How to access a photo that is upload into another project in the same solution 如何从相同解决方案的另一个项目中加载文件 - How to Load a file from another project of same solution 在相同解决方案下从另一个项目访问文件 - access file from another project under same solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM