How can I develop a C# application to open a page in a web browser, given the URL, and refresh it continuously (always the same URL)?
Open URL and refresh it continuously from C# app
Collapse
X
-
I am assuming by the fact that you say you want to refresh it continuously, you have no plans to USE the site, only to view it. If that is the case, you could just as easily make your own web browser with WinForms. The WebBrowser Control would allow you to display a page in it's own window. You would have total control over what page is shown and when it refreshes.Comment
-
Yes, the page is displaying images only and I want to refresh it to change the image displayed. But this is a solution for the client side.
Now I was wondering if there is any chance to do this on the server side, that is: user opens url in web browser and server changes the image to be displayed and refreshes the page automatically. Is this possible? How can I do this? Thanks.Comment
-
I used the example posted here http://msdn.microsoft.com/en-us/library/3s8ys666.aspx to learn about the WebBrowser Control but I'm having trouble to refresh it continously.
I tried to do this:
But nothing happened. How can I do this? Thanks!while(true) //just to make it simple
{
webBrowser1.Ref resh();
Thread.Sleep(20 0);
}Comment
-
Well I solve the question above using a thread.
But I still want to develop an alternative solution that is server-side only. Summarizing: I want to build a web page on a server side that displays images, one at a time, once each one is saved on a folder, so that the client opens the URL only once and it is continuously refreshed so that he can watch the sequence of images as a video.
Can somebody help me?Comment
-
You're going to hammer the server every 200 ms - continuously? Obviously this isn't *your* server. Have a little respect for other people's sites.Code:while(true) //just to make it simple { webBrowser1.Refresh(); Thread.Sleep(200); }
You know many hosting providers have a limit of downloaded data. Its not an issue if you are running your own site. But if you are paying a company to host for you... once you hit that 20gig a month limit or whatever it either costs you a lot extra or they just shut you off.Comment
-
So you are talking about a slideshow? Doesn't it make more sense to use something like javascript or perhaps http://www.asp.net/AJAX/AjaxControlT...SlideShow.aspx?
People are going to insta block you if you spam their site like this trying to refresh 5 times a second.Comment
-
This is for an academic project - streaming a small video (as a sequence of images), the server is used for these kinds of researches and images are about 5 kB size, so it's ok.
This isn't the core of the project so I was looking for a simple and easy solution. I don't know anything about javascript or AJAX. Is there any other simpler solution for my problem that you can think of?
Thanks.Comment
-
I developed this application for the server:
How ever I dont know how to replace and display the new image.Code:namespace DisplayImages { public partial class _Default : System.Web.UI.Page { string DirectoryPath = "C:\\Users\\VSProject\\Uploads\\"; protected void Page_Load(object sender, EventArgs e) { FileSystemWatcher watcher = new FileSystemWatcher(); try { watcher.Path = DirectoryPath; watcher.Created += new FileSystemEventHandler(watcher_Created); watcher.EnableRaisingEvents = true; Image image = Image.FromFile(DirectoryPath + "initial.jpg"); MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] im = ms.ToArray(); Context.Response.ContentType = "Image/JPG"; Context.Response.BinaryWrite(im); } catch (Exception ex) { } } void watcher_Created(object sender, FileSystemEventArgs e) { Console.WriteLine("File Created: Name: " + e.Name); try { //How to replace and display new image? } catch (Exception ex) { } } } }
Somebody help?
Thanks.Comment
-
Bytes has a policy regarding assisting students with their homework.
The short version is that the volunteers here can't help you with schoolwork.
A) We don't know what material you have and have not learned in class.
B) We don't know the guidelines you must follow.
C) In the long run giving you the answers actually short changes your education.
Hint 1: Try hitting Google with terms of your programming language and primary terms of what you want to do. For example "C# custom events" or "VB datagrid Excel". I've found this to be a very effective tool.
Hint 2: Your text book
Hint 3: Your instructor
Hint 4: Posting guidelines regarding homework assignments.Comment
-
A question on syntax/usage of the .NET framework doesn't seem so bad to me :)
I played around with a web browser object a while back (***) and noticed that the refresh method had a couple options.
There's a completely option, that might work for you? Check out... http://msdn.microsoft.com/en-us/library/ts4tye44.aspx
That said, I kind of agree with the other posters here... there's gotta be a better solution than to refresh a web browser looking at an image. That solution would be for you to find out though ;)
*** Heads up, when I was playing around with this I was using google as the page I was going to and actually managed to get temp banned from Google! I know what you're thinking, but I wasn't doing anything untoward. I was just making a stripped down internet explorer to see how the functionality worked, but I guess Google doesn't like it. It detects it as an automated query. So I don't know if it's a bug with the web browser behaviour or if Google is too smart for it's own good, but I figured I'd point it out anyway.Comment
Comment