Using System.Diagnostics.Process() to print traceroute information on webpage

H

Heiko Besemann

Dear group,

I created an aspx page using System.Diagnostics.Process() to launch
"tracert" from shell and redirect output to Response.Output which
prints it as text/plain into my browsers window. Now that works fine
so far. My problem is that while tracert process is running and ASP
..NET is putting data into the pages output stream, my webapplication
is locked until tracert process exits. How can I stop locking my
application and be able to display other aspx pages while tracert is
running?

Thanks for your help!

Heiko Besemann



Here is my example code...

-- snip --

private System.Diagnostics.Process p;

private void Page_Load(object sender, System.EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Parse("1.2.1973 07:00:00"));

Page.Response.Clear();
Page.Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition","filename=\"traceroute.txt\"");
Response.BufferOutput = false;
Page.Response.Output.Write("TraceRoute bearbeitet Anfrage -- bitte
warten!\n\n");
Page.Response.Flush();

p = new System.Diagnostics.Process();
p.StartInfo.FileName = "c:\\windows\\system32\\tracert";
p.StartInfo.Arguments = Request.Params["ip"]; //"217.88.223.186";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
p.PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal;

while (!p.HasExited)
{
strTemp = p.StandardOutput.ReadLine();
if(strTemp.Length > 3) Page.Response.Output.Write(strTemp+"\n");
Page.Response.Flush();
if(!Response.IsClientConnected)
{
p.Kill();
break;
}
}
Response.Flush();
Response.Close();
}
 
H

Harsh Thakur

Hi,

Just a thought.
Have you considered launching "tracert" on a seperate
thread?

HTH
Regards
Harsh Thakur
-----Original Message-----
Dear group,

I created an aspx page using System.Diagnostics.Process() to launch
"tracert" from shell and redirect output to Response.Output which
prints it as text/plain into my browsers window. Now that works fine
so far. My problem is that while tracert process is running and ASP
..NET is putting data into the pages output stream, my webapplication
is locked until tracert process exits. How can I stop locking my
application and be able to display other aspx pages while tracert is
running?

Thanks for your help!

Heiko Besemann



Here is my example code...

-- snip --

private System.Diagnostics.Process p;

private void Page_Load(object sender, System.EventArgs e)
{
Response.Cache.SetCacheability (HttpCacheability.NoCache);
Response.Cache.SetExpires
(DateTime.Parse("1.2.1973 07:00:00"));
Page.Response.Clear();
Page.Response.ContentType = "text/plain";
Response.AppendHeader("Content- Disposition","filename=\"traceroute.txt\"");
Response.BufferOutput = false;
Page.Response.Output.Write
("TraceRoute bearbeitet Anfrage -- bitte
warten!\n\n");
Page.Response.Flush();

p = new System.Diagnostics.Process ();
p.StartInfo.FileName
= "c:\\windows\\system32\\tracert";
p.StartInfo.Arguments =
Request.Params["ip"]; //"217.88.223.186";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,829
Messages
2,569,737
Members
45,525
Latest member
RosalindSa

Latest Threads

Top