vb.net - "The remote server returned an error (502) Bad Gateway" while downloading image file from url -


i trying download image website, gives me error i.e. (the remote server returned error: (502) bad gateway). search lot on internet didn't exact solution. code working on website on few website showing above error. please check below code...

private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load     dim filename string = application.startuppath     if not filename.endswith("\") filename &= "\"     txtlocalfile.text = "d:\a.jpg" 'filename & " "     txtremotefile.text = "http://bseworld.bseindia.com/eventgallery/cricket2015/19feb2015/2.jpg" end sub   private sub btndownload_click(byval sender system.object, byval e system.eventargs) handles btndownload.click     application.doevents()     try         dim web_client webclient = new webclient          dim wp = new webproxy("proxy ip", proxy_port)         wp.credentials = new networkcredential("uname", "password", "domainname")         web_client.proxy = wp         web_client.downloadfile(txtremotefile.text, txtlocalfile.text)          messagebox.show("done")     catch ex exception      end try      end sub 

can please tell me part of code missing or have change..

i did rnd , code working.

private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load     dim filename string = application.startuppath     if not filename.endswith("\") filename &= "\"     txtlocalfile.text = "" 'filename & " "     txtremotefile.text = "" end sub  private sub btndownload_click(byval sender system.object, byval e system.eventargs) handles btndownload.click     application.doevents()     dim web_client webclient = new webclient     try         web_client.usedefaultcredentials = true         web_client.downloadfile(txtremotefile.text, txtlocalfile.text)         messagebox.show("done")      catch ex exception         dim wp = new webproxy("proxy ip", proxy_port)         wp.credentials = new networkcredential("machineusername", "machine password", "domain name")         web_client.proxy = wp         web_client.downloadfile(txtremotefile.text, txtlocalfile.text)         messagebox.show("done")     end try  end sub 

Comments