I have setup a network path on the web server running the .net MVC application to another server that is being used for storage of files that are uploaded. In order to allow for uploading files to the network path through the application I amended the application pool in IIS so that the application had permission to upload to it. This all works fine.
In order for the app to read the file when loading a page I created a virtual directory in IIS which appears now as part of the file system for that site in IIS. How can I then access and generate a path for this location in my app so that the path can be passed to a DB and then the image loaded later on a page?
Let's say my path is:
virtual path is useruploads/image.jpg
How can I have my application recognise the virtual path I've created?
Alternatively scrapping the virtual directory in IIS, is there a way I can have my application access the network path on the web server directly?
edit - To add to the above I have the network path mapped in iis and it shows under my site in iis as follows:
I would like to then read from this directory inside the asp.net mvc app using an address like this ~/useruploads/file.jpg. If I can get my app to recognise this virtual directory then I will be able to read from it.
edit no.2
Ok I think I have determined the nature of my issue and am a lot clearer. Basically I am accessing the file just fine when I link to it on the webpage. However I get the message 'not allowed to load local resource' in chrome. I believe this is simply a question of web browsers not allowing me to load the image because it is referenced on the page with a local address (the network path). As such I am now trying to create an action in the application to load the image with Url.Action directed at my action which will then convert the id into a stream of the image e.g.
In my view:
<img src="@Url.Action("image", "files", new { image = Model.image})" alt="name" />
Where Mode.image is something like folder\image.jpg.
Action:
public FileResult image(string id)
{
var dir = @"\\SERVERNAME\upload\";
var path = Path.Combine(dir, id);
return base.File(path, "image/jpg");
}