Web Hosting Talk







View Full Version : Calling an External Executable with ASP.NET


tjc1027
10-20-2004, 01:07 PM
I have a page on my companies site that needs to access terrain data on our servers to find the elevation of a certain Latitude and Longitude. We have a command line executable that does this. I am trying to make asp.net call this executable and get the output from it. What I am running into is this works fine with a Windows Forms application but once I move my code to a WebForms App it stops working.

Here is my Code:

System.Diagnostics.Process FindElev = new System.Diagnostics.Process();
FindElev.StartInfo.Arguments = "33-15-38.6 83-14-56.8";
FindElev.StartInfo.UseShellExecute = false;
FindElev.StartInfo.FileName = "C:\\InetPub\\wwwroot\\FindElev\\FindElev.exe";
FindElev.StartInfo.ErrorDialog = true;
FindElev.StartInfo.RedirectStandardOutput = true;
FindElev.Start();
string Meters = FindElev.StandardOutput.ReadToEnd();
string Test = Meters;



I have just been putting a breakpoint at the last line and checking the contents of Meters with the debugger in VS.NET which shows 0 in ASP.NET and 100 in a Windows App (which is correct). Does anybody know why this code would stop working when added to an ASP.NET app but work in a Windows Forms App? Is there a way to do this in ASP.NET?

tjc1027