1 Replies - 1378 Views - Last Post: 02 November 2014 - 05:23 PM

#1 Nana Nyarko Abronomah   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 42
  • Joined: 03-November 10

Displaying Server side progress in client's browser

Posted 02 November 2014 - 04:04 PM

I am running some server side processes and i want to display the progress in the browser automatically. unfortunately i'm unable to get around it. This is what i tried

        For i As Integer = 0 To 10000
            Response.Write("<script>mydiv.innerText = '" & CStr(i) & " of 10000';</script>")

Is This A Good Question/Topic? 0
  • +

Replies To: Displaying Server side progress in client's browser

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Displaying Server side progress in client's browser

Posted 02 November 2014 - 05:23 PM


Regarding that code. That's a very bad way of looking at the client-server relationship. It's pretty much doomed to fail.

The problem with what you did is that you are trying to control client-side behaviour on the server-side, but there are a myriad of issues when it comes to that, from output buffering on the HTTP server, to connection timeouts, and probably a load of other ASP.NET specific issues I don't know off. (I'm more of a PHP/NodeJS/Python kind of guy.)

Controlling client-side behaviour is a job for Javascript.

What you want to do is have the client-side query the status periodically using AJAX: Issue AJAX requests every now and then on a timer, and have the server respond with the current status of the processes. Then display that via Javascript.

Alternatively, if you are up for something a little more modern than AJAX, you can look into implementing the same using WebSockets. Those will get you a persistent connection between the client and server, and you can push updates down to the client as they become available.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1