0

I have continuous operation on web-server (read-write cycle from sourceFTP to targetFTP with many transformation data). Technology of my site is ASP MVC 3. How I may write to my web-page result of which successful portion of my operation - such as Response.Write, but my page is very complex (master page and many controls). For example

Function Start() As ActionResult

  while true
  ...
     Response.Write (".") 'How to do this???
  ...
  End While

End Function
Кацап
  • 13
  • 4
  • Please add more details to your question... I think you can use AsyncController for these kind of operations along with ajax polling. http://stackoverflow.com/questions/11117421/how-to-do-long-polling-properly-in-mvc-3 – Sandeep Kumar M Jul 08 '15 at 11:38
  • My operation continues more than one hour and I want have see online notification every seconds, every small steps for processing my operations. Before the given time I did not use AsyncController. That's exactly what I'm looking for? – Кацап Jul 08 '15 at 11:49

1 Answers1

0

You generally don't use Response.Write() in an MVC application. And you definitely don't use an infinite loop, since it would cause the page to never finish processing and never be sent to the browser.

If I understand correctly, you want to display a page to the user and have that page constantly update with information from the server. If that's the case then you don't want the long-running process to be on the page, you want it separated from the page. The page just presents the UI, which is going to contain some JavaScript code to update the UI based on data received from the server.

In order to push updates from the server to the browser, take a look at SignalR. There are a couple of different ways to do it, depending on what the browser supports, and this library abstracts them nicely.

Specifically, this walk-through sounds like it's very close to the functionality you're looking for. There's a server-side loop to process information and a client-side loop to update the UI in response to that information. And SignalR simply provides the communication channel between the two.

Essentially what you're asking is not a trivial operation and is somewhat broad. But the basics of it are that you can't just expect the browser and the server to communicate in real-time on their own. You need to write the code which does that.

David
  • 208,112
  • 36
  • 198
  • 279
  • Yes, you correctly understand my problem. I am reading externally about SignalR, but implementation of this library is not simple. – Кацап Jul 08 '15 at 12:04
  • @Кацап: The concept itself is deceptively complex. Basically once you understand how HTTP requests/responses work, you can see how the pieces fit together. Essentially the "page" is a single request/response, entirely separate from the data being updated on the page in real-time. That data is then going to have to be transmitted via web sockets or via polling (which is a series of requests/responses). Multiple technologies are going to be required for this, you're going to need to understand JavaScript in order to make any kind of dynamic web UI. – David Jul 08 '15 at 12:13
  • Thank you, I undersand JavaScript and I understand how to ASP MVC working, but I think that ASP.NET MVC already contains built-in mechanisms to solve this problems. Is there an easier way than SignalR ? – Кацап Jul 08 '15 at 12:20