Reputation: 35
I have an Image Path which is of D: drive and I want to display that Image on my Image Control of asp.net.So, how to provide file path to Image.ImageUrl?
"D:/Folder/001_001.jpg"
I tried with server.MapPath() method but doesn't work.
Upvotes: 0
Views: 3259
Reputation: 338
If you're deploying in IIS, you could create a virtual directory Images
that would point towards D:/Folder
, then you could set your ImageUrl to ~/Images/001_001.jpg.jpg
.
An alternative solution could be to create a symlink between the two folders. You would run something like the following in cmd mklink /D ""D:/Folder" "[YouProjectPath]/Images"
, then set your ImageUrl to ~/Images/001_001.jpg.jpg
. I would stay away from this though as it would only work on a machine where the project lives in the exact same path as yours.
Upvotes: 1
Reputation: 2924
You can make local path as following "file:///D:/Folder/001_001.jpg
".
However, it's strongly not recommended to use this practice even if your site is planned to stay on your local computer only and will never been deployed to real Internet. You should copy / upload the file to your site's subdirectory 'Images' and then use the relative path '~/Images/001_001.jpg
'.
Upvotes: 0