Search code examples
asp.net-mvccross-domainsubdomain

Displaying images from subdomain in root directory (ASP.NET)


I have a domain e.g. example.com and a subdomain manage.example.com. When adding news on the management site, I save the pictures in the Image folder located in the manage.example.com subdomain.

I am trying to use these images in the views of the root site (example.com) using img tags. I gave the full path example.com/subdomains/manage/image/imagename.jpg but nothing is shown. The path is apparently invalid but this is the path I get when I connect via FTP.

How can I display those pictures?


Solution

  • The path used by FTP (which might be expected to correspond to a path on the server's disk) is not necessary the same as the path which is accessible via the web. The two things do not have to correlate at all - a webserver can be configured to present a totally different picture to what is logically there on the disk.

    If you're displaying the images on a webpage then you need to use the URL of each image in your HTML, just the same as if you had browsed directly to it. If it's a subdomain as you described then it's more likely going to be something along the lines of

    <img src="http://manage.example.com/image/imagename.jpg"/>
    

    But you'll need to check your webserver's config to see how the subdomain is set up and where the root folder of it is set to.