Search code examples
c#wcfiis-8

WCF URLDownloadToFile in IIS fail download


I have a WCF application that downloads a file from an external web, in development mode it works perfect, but on the IIS server it does not download the file.

URLDownloadToFile(0, "URLFile", HttpContext.Current.Server.MapPath("~/temp/") + "img.gif", 0, IntPtr.Zero);

some help?


Solution

  • URLDownloadToFile is part of WinInet, which is not supported under a windows service like IIS. See INFO: WinInet Not Supported for Use in Services for details.

    Since you are using WCF, a more natural way to download files is to use the WebClient class in System.Net.