0

I'm creating a solution for an online store in ASP.net MVC5. My solution consists of four Projects,

  1. Store.Data for my database entities, edmx file and partial classes for products,

  2. Store.POS is the mobile app for making payments, a point of sale, as the name suggests.

  3. Store.Admin for handling inventory management, updating new products and prices and viewing sales and generating reports.

  4. Store.Client is the online store.

All the projects use one database, that means a similar connection string in the web.config for each web project, and I'm using Web API for the mobile app.

My problem is

How do I make one folder accessible between Store.Admin and Store.Client, that will store images for products? Store.Admin creates products and uploads images and Store.Client reads those images

Apparently Store.Admin and Store.Client was one project, but I split the two because even managing Areas was making one project more cumbersome. That is why I had to split to make my code more manageable.

I tried a number of solutions including this one Two MVC projects - Image sharing

and the solution is suggesting that i go back to Areas

It'll be ok if i can access a Product image, by this line example, in the partial class of Product, ID being the ID from DB, and "~/Images/" being the shared folder that i need to access between these projects

 public string ImagePath => $"~/Images/{ID}/";
Liam
  • 27,717
  • 28
  • 128
  • 190
welly
  • 41
  • 2
  • Just put the images in a common place? Put the path to the location in config out the same config in both projects. Seems pretty simple to me? – Liam May 09 '19 at 11:45
  • 1
    You could create a web site that is strictly for static files that hosts your images or have a CDN do that for you. – Crowcoder May 09 '19 at 11:47
  • Or just create an API that will service the files for you, then reference the API via any app – mahlatse May 09 '19 at 11:52

1 Answers1

0

If you run a simple, low-traffic ASP.NET MVC web application (e.g. you're just developing internal webapps for a business or are working on a personal/school project), you can simply dump the images into an absolute-path folder like C:\myfoldername\images instead of using the relative paths like in your question.

If you host in Azure and those images will conceivably be accessed by multiple servers, consider keeping those images in blob storage and accessing them there.

Slothario
  • 2,830
  • 3
  • 31
  • 47