Remote file is not getting accessed if path comes from web.config

0

In web.config,

 <add key="Uploads"  value="\\\\192.19.165.115\\image_dir\\"/>

C# code:

 uploadsPath = (ConfigurationManager.AppSettings["Uploads"].ToString()); 

Its returning file with below statement

return File("\\\\192.19.165.115\\image_dir\\" + name, System.Net.Mime.MediaTypeNames.Application.Octet, name);

But, it is throwing below error with this line of code.

return File(uploadsPath + name, System.Net.Mime.MediaTypeNames.Application.Octet, name);

Error:

[COMException (0x80070006): The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))]
[HttpException (0x80004005): An error occurred while communicating with the remote host. The error code is 0x80070006.]

Both are same paths. Please guide me to solve this issue.

c#
asked on Stack Overflow Mar 30, 2015 by lavanya b • edited Mar 30, 2015 by lavanya b

1 Answer

0

In Web config the value should be this:

 <add key="Uploads"  value="\\192.19.165.115\image_dir\"/>
answered on Stack Overflow Mar 30, 2015 by Radin Gospodinov

User contributions licensed under CC BY-SA 3.0