Adam
Adam

Reputation: 45

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

i have solution where are three project (Intranet, Site, and Data). In Intranet i have form where I add new Restaurant object (name, description, photo and etc.). Photos are saved in Path Intranet/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?

Upvotes: 0

Views: 775

Answers (1)

user2316116
user2316116

Reputation: 6814

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

i.e. if Intranet 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.

Upvotes: 1

Related Questions