472,805 Members | 1,117 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

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

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.No Cache);
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();
}
Nov 18 '05 #1
1 2981
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 whichprints it as text/plain into my browsers window. Now that works fineso far. My problem is that while tracert process is running and ASP..NET is putting data into the pages output stream, my webapplicationis locked until tracert process exits. How can I stop locking myapplication and be able to display other aspx pages while tracert isrunning?

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 -- bittewarten!\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();
}
.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Barry Munro | last post by:
Hi, I'm using the following code to print documents from the file system but i'm encountering strange behaviour. If I print one document it works ok but if i say loop round a list of files and...
1
by: Sriram | last post by:
Hi. Following code works fine on XP, but not on W2K+SP4. When I run it on W2K, it does not give me any error, exception. I have tried setting StartInfo.ErrorDialog = True,...
0
by: Daniel Reber | last post by:
I am trying to start a process from a windows service but when the process starts the command window that the process runs in never shows. Is this because I am calling it from a windows service? ...
1
by: Morten | last post by:
Hi! Does anyone know why the code below always returns an "access is denied" error? private void Page_Load(object sender, System.EventArgs e) { System.Diagnostics.Process meProc =...
2
by: Ram | last post by:
Hey, I'm trying to use the following code inside an ASP.NET project: System.Diagnostics.Process objProcess; objProcess = new System.Diagnostics.Process();...
5
by: garyusenet | last post by:
I have been trying for some time now to launch Internet Explorer from my code. I have read the MSDN notes on this way of starting processes and used their example but couldn't get it to work. I...
0
by: Speech Lover | last post by:
I am trying to find a sample from the Internet about invoking a command line from .NET 2.0 by using System.Diagnostics.Process with Domain, UserName and Password specified? All samples I found so...
3
by: Bali | last post by:
Hi I have an ASP.NET application. I am on the server side and trying to start an application which is on the server. The process gets started(can be seen in the Task Manager) but doesn't do...
2
JnrJnr
by: JnrJnr | last post by:
Hello. I am trying to open a .EXE file with the System.Diagnostics.Process.Start(some file path .exe) command. It works for most programs and apps but for others programs I get a warning message box ...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.