简体   繁体   中英

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). In Intr.net i have form where I add new Restaurant object (name, description, photo and etc.). Photos are saved in Path Intr.net/wwwroot/images/items and link to the photo is saved in database like this:

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? 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 .

ie if Intr.net path for images is

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

C:\inetpub\wwwroot\images\items 

This will let you to access same images as ~/images/items/ in the Site project.

Another approach would be to create an image handler that will programmatically access required file and output it to the browser as an image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM