Link to home
Start Free TrialLog in
Avatar of Sudhanshum
Sudhanshum

asked on

File upload using Virtual Directory on different server getting failed

I have created Virtual Directory named as Downloadserver on my website IIS (192.168.1.1\Download), That 192.168.1.1 is another server, while website is setup on 192.168.1.2,  , Now I am trying to upload file there using below code:
 Dim filenamepath As String = System.IO.Path.Combine(Server.MapPath("~/DownloadServer/"), fuSheet.FileName)
 fuSheet.PostedFile.SaveAs(filenamepath)

 But its not uploading file on \\192.168.1.1\Download location, Please help me to understand this.
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

In general, Server.MapPath will map to the directory of the web site, which is 192.168.1.1.

in order to access to a directory at server: 192.168.1.2, I would suggest you create a mapped drive which you have been granted read/write access by IIS_IUSRS, for example. And then finally, refer to that mapped drive to save your uploaded file.
Avatar of Sudhanshum
Sudhanshum

ASKER

Can we create mapped drive using Asp.net, Problem with manual mapped drive is that if it get disconnected then Production upload, Download will fail.
Can we create mapped drive using Asp.net, Problem with manual mapped drive

for me, it would be not practical to do drive mapping via ASP.NET if that's possible.

the mapping of drive can be automated when the server is starting up. And we only need do it once for that.
is that reliable method to map drive once?
I did not understand concept of Virtual Directory on Website through IIS, what is use of that if it doesnt connect with defined server?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.