2

I'm currently developing a webpage that calls a C# console application executable on the server. This is great, however, I'd really like to be able to stream the console application output in real time to a textbox on the application that called the application. I have managed to redirect the output of the console to a text file after the console application has completed, but what would be great would be to find out how to stream in real time from the application as it runs to a text box on the webpage.

mclark1129
  • 7,532
  • 5
  • 48
  • 84
  • 1
    possible duplicate of [Capturing console output from a .NET application (C#)](http://stackoverflow.com/questions/186822/capturing-console-output-from-a-net-application-c) – Moo-Juice Jan 08 '14 at 13:54
  • Any reason you're not using a web service? Web API and Ajax/Web Sockets would make this simple. – Mister Epic Jan 08 '14 at 13:55
  • You do not push from a server to a web client. The client has to pull the information. – Alexander Jan 08 '14 at 13:56
  • What are you using MVC,webforms ? You cannot do it with C# Alone! – techno Jan 08 '14 at 13:57
  • Thanks for responses everyone. No Moo-Juice, I can quite easily do that as stated.. @Chris Hardie thanks, will look into this.@techno I am using MVC webforms through vis. studio 2012.. – user1963870 Jan 08 '14 at 14:15
  • See also -https://stackoverflow.com/questions/20978819/update-panel-to-display-output-from-console/20978885#20978885 – ChrisF Oct 25 '18 at 10:52

2 Answers2

1

This is not a simple scenario that you can accomplish with C# alone.You have to use AJAX(Jquery)

Here is a link to an example that discuss regarding the creation of realtime log.

http://forums.asp.net/t/1602013.aspx

You will need to use UpdatePanel

techno
  • 6,100
  • 16
  • 86
  • 192
0

Have your web page, serverside, read the txt file and put the read text into any control you like. Then have your web page refresh itself / that control every 10 seconds.

Alexander
  • 2,457
  • 1
  • 14
  • 17
  • "real time" Is what the OP asks – techno Jan 08 '14 at 14:00
  • Thank you both for your advice. Alexander, I will work for this as a work around and in the interest of saving time. Thanks again for your help @techno – user1963870 Jan 08 '14 at 14:17
  • 1
    @techno Alexander is correct. Real time is not possible. There will always be a display as the AJAX has to poll the server at an interval. You can make it relatively short so that it's hardly noticeable though. – mason Jan 08 '14 at 14:31
  • 1
    Real time is possible with Web Sockets, if supported. – Mister Epic Jan 08 '14 at 14:38
  • @msm8bball Yes,the code needs time to run and pull data.I did not mean the the date will be printed as soon as it generated by the system.This is better and almost as realtime rather than refreshing the page 10seonds you can do it with AJAX with much less time.Giving a real time simulation. – techno Jan 08 '14 at 14:41
  • 1
    @techno This is still not real time. AJAX (unlike Web Sockets, thanks @ChrisHardie) polls the server at a specified interval. You're just going to confuse things if you get the terminology wrong. – mason Jan 08 '14 at 14:47