在web.config中,
<add key="Uploads" value="\\\\192.19.165.115\\image_dir\\"/>
C#代码:
uploadsPath = (ConfigurationManager.AppSettings["Uploads"].ToString());
使用以下语句返回文件
return File("\\\\192.19.165.115\\image_dir\\" + name, System.Net.Mime.MediaTypeNames.Application.Octet, name);
但是,使用这行代码会导致错误。
return File(uploadsPath + name, System.Net.Mime.MediaTypeNames.Application.Octet, name);
错误:
[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.]
两者都是相同的路径。请指导我解决这个问题。
答案 0 :(得分:0)
在Web配置中,值应为:
<add key="Uploads" value="\\192.19.165.115\image_dir\"/>