title: Accessing images in a different project, but in the same solution
body: <p>I made this website for a client which wanted to be able to upload images and then use those images to create some dynamic content on his site. It all works fine, but now I want to isolate that administration part (where he can add images and create his content) on a subdomain.</p>
  <p>So at the moment, I have two projects. One where images get uploaded to, and <strong>one who has to access those images</strong> (this is my problem).</p>
  <p>I have read multiple topics related to this issue but have not found a solution, I can never get a path outside of my current project.</p>
  <p>The only option I am thinking right now that could work is to have some kind of API on the main website, and when an image gets uploaded to the administration site, send that file over to the main site, but that seems pretty overkill knowing that my images will be on the same server.</p>
  <ul>
  <li>Can this be done?</li>
  <li>What is the cleanest/best way to achieve this?</li>
  </ul>
  <p>Please note:</p>
  <ul>
  <li>Saving images to the database is not an option. Uploading files on the server and then only storing the path is so much faster.</li>
  <li>My images get uploaded at run-time, I can't use anything that relies on resources/compilation-time.</li>
  </ul>
  <p>Thanks!</p>
  <h1>UPDATE (SOLUTION)</h1>
  <p>Rather than saving in the database only the name of the file (image), for example &quot;image1.png&quot; and then trying to retrieve the path in the other project, I ended up saving the absolute URL in the database so that I could then use that URL directly.</p>
  <pre><code>public static string ResolveServerUrl(string serverUrl, bool forceHttps)
  {
    if (serverUrl.IndexOf(&quot;://&quot;) &gt; -1)
      return serverUrl;
  
    string newUrl = serverUrl;
    Uri originalUri = System.Web.HttpContext.Current.Request.Url;
    newUrl = (forceHttps ? &quot;https&quot; : originalUri.Scheme) +
                  &quot;://&quot; + originalUri.Authority + newUrl;
    return newUrl;
  } 
  </code></pre>
  <p>This will give you a URL that looks like <code>http://yourdomain/path/to/image.jpg</code>, so you can save it directly in the database and use it as is in the other project.</p>