C # webbrowser not showing updated result

Hi guys, I have problems with the web browser or maybe ftp .. I upload a picture, and when I navigate the web browser, it shows me an old photo, but the image im uploading gets to ftp and is overwritten .. heres code

webBrowser1.Refresh(WebBrowserRefreshOption.Completely); webBrowser1.Navigate("www.google.com"); openFileDialog1.ShowDialog(); string filename = Path.GetFullPath(openFileDialog1.FileName); FileInfo toUpload = new FileInfo(@"upload.jpg"); FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://fingercube.co.cc/public_html/objimg/" + toUpload.Name); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential("username", "pass"); Stream ftpStream = request.GetRequestStream(); FileStream file = File.OpenRead(filename); int lenght = 2; byte[] buffer = new byte[lenght]; int bytesRead = 0; do { bytesRead = file.Read(buffer, 0, lenght); ftpStream.Write(buffer, 0, bytesRead); } while (bytesRead != 0); file.Close(); ftpStream.Close(); webBrowser1.Navigate("http://fingercube.co.cc/objimg/"+toUpload.Name); 

he shows me an old photo every time .. but the photo is uploaded every time !: (

+4
source share
3 answers

If the caching suggestion does not work, try the following.

 this.webBrowser1.Navigate("about:blank"); HtmlDocument doc = this.wbbFinalise.Document; doc.Write(string.Empty); 

Then go to the ftp location.

I had a similar problem trying to update a locally generated HTTP page in a web browser and this fixed the problem.

0
source

The image is cached in IE cache. You must clear the cache before updating the control. Have a look here: http://www.gutgames.com/post/Clearing-the-Cache-of-a-WebBrowser-Control.aspx

Also, related SO question: WebBrowser management caching issue

0
source

got a solution .. the problem was that the cache was a simple solution was to make a new request each time.

-1
source

Source: https://habr.com/ru/post/1444576/


All Articles