Home > other >  Access wwwroot folder from another project within the same solution
Access wwwroot folder from another project within the same solution

Time:05-25

I'm very new to ASP.Net and I have an images folder within wwwroot that I'm attempting to access from another project within the same solution.

I have my first project ProjectWebApp that contains the wwwroot/images folder..

Then I have my second project ProjectWebApp.Data that contains a mock database. The objects there have an Images property that should be a string path to images/image.jpg. But since that path is in the first project, it won't work. So I'm not quite sure how to set this up.

CodePudding user response:

Short answer: Project2 should not have access to Project1/wwwroot

There are a few missing pieces of information, but the general idea is; If you have a cross-cutting concern then you decompose. In this case, since you do not want to create 2 copies of images for each project, the images should go in another place where both ProjectA and ProjectB can access them.

Depending on what the goal is there are different ways to solve.

Local Development: Create a 3rd project (I would pick a "Web Site Project" that simply serves the image files)

IIS: Utilize Virtual Directories

Cloud Solution: Move all the images to Blob Storage (Azure Storage / Amazon S3)

  • Related