0

I'm trying to download a .axd picture link, but I'm getting not found error(404). In local server, works fine, but I get 404 on production Server. Is there anything I must to set up in web.config or something?

    public System.Drawing.Image DownloadImage(string url)
    {
        using (var webClient = new WebClient())
        {
            byte[] fileBytes;
            try
            { 
            fileBytes= webClient.DownloadData(url);
            }
            catch (WebException ex)
            {
               // (HttpWebResponse)ex.Response).StatusCode
                Util.GerarLog("DownloadImage", ex.Message + " " + ex.InnerException + "URL: " + url + "Response: " + ((HttpWebResponse)ex.Response).StatusCode.ToString(), "Image");
                throw new Exception(ex.Message + " " + ex.InnerException);
            }
           return ByteArrayToImage(fileBytes);
        }
    }

    public static System.Drawing.Image ByteArrayToImage(byte[] fileBytes)
    {
        using (var stream = new MemoryStream(fileBytes))
        {
            return System.Drawing.Image.FromStream(stream);
        }
    }
  • quick question.. have you tried a `Google Seach` on Stackoverflow for `WebClient.DownLoad` I am pretty sure there are numerous working examples on this site as well as on the Internet in general.. I also see quite a few problems with your `fileByte` variable.. how come you do not initialize the size of `fileByte` I would try this for example `byte[] fileByte = new byte[1024];` – MethodMan Jan 29 '15 at 19:31
  • I surely tried, they often sugest changes in web.config which I already did – user2789032 Jan 29 '15 at 19:46
  • this has nothing to do with the web config.. what are you talking about .. considering what you have written in your code has no reference to the web.config file – MethodMan Jan 29 '15 at 19:49

0 Answers0