How would I code it using server.maptpath? I'm pretty sure that something must be place between the "\" and "EmailDistributor.exe" to get to the right application.
Running the app on a webserver is going to put the application in a different path. I want to know what that path would be by using the server.mappath and the location of the console app.
The path where the web app and console app will be are in two different paths. Based on this scenario, what should the server.mappath statement look like?
If the console application is outside the web root, you're either going to have to hard code the path or you'll need to create a web folder that points at the console apps home folder.
Mark as answer posts that helped you.
Marked as answer by wsyeager36 on Apr 11, 2012 12:51 PM
btw, just to be sure, once the web form passes the info to the console app, the web application will relinquish control? I won't have to wait for the console app to finish if users want to move around elsewhere in the web application?
I think process.start acts like an independent process but just to be sure I would suggest testing it. To be honest, I haven't tested process.start that way.
wsyeager36
Member
385 Points
458 Posts
Running a console app from a web form
Apr 10, 2012 04:50 PM|LINK
I have a large existing application where I need to call a console app from a code behind page.
I know how to do the above, but what I need help with is the FileName property for the ProcessStartInfo object.
The applciation has many folders all with executables and I want to make sure I am coding the correct path to the exe I want executed.
On my local machine, the specific exe I want executed is below.
"C:\projects\ABB\Source\AbbSolutions\Source\Utilities\EmailDistributor\bin\Debug\EmailDistributor.exe"
How would I code it using server.maptpath? I'm pretty sure that something must be place between the "\" and "EmailDistributor.exe" to get to the right application.
Server.MapPath(@"\EmailDistributor.exe") ????????
Bill Yeager
MCP.Net, BCIP
bbcompent1
All-Star
32994 Points
8509 Posts
Moderator
Re: Running a console app from a web form
Apr 10, 2012 05:22 PM|LINK
Running a console app from a web app is handeld in code behind as
Process.Start("C:\projects\ABB\Source\AbbSolutions\Source\Utilities\EmailDistributor\bin\Debug\EmailDistributor.exe");wsyeager36
Member
385 Points
458 Posts
Re: Running a console app from a web form
Apr 10, 2012 06:38 PM|LINK
Bill Yeager
MCP.Net, BCIP
bbcompent1
All-Star
32994 Points
8509 Posts
Moderator
Re: Running a console app from a web form
Apr 10, 2012 06:44 PM|LINK
Ok, if your console app lives under the web folder structure then just call out to it like you would a normal web folder:
Process.Start("~/directory/ConsoleApp.exe")
nirman.doshi
Participant
1520 Points
775 Posts
Re: Running a console app from a web form
Apr 10, 2012 06:48 PM|LINK
you can pass the path, depending upon the relativity of folder paths between your page and EXE.
Orelse, you can also give hardcoded path as suggested by bbcompoent1
In case, if they are in very same path then following should work:
Process.Start(Server.MapPath(@"EmailDistributor.exe"));
Software Developer
Vadodara, India
wsyeager36
Member
385 Points
458 Posts
Re: Running a console app from a web form
Apr 10, 2012 07:06 PM|LINK
Bill Yeager
MCP.Net, BCIP
bbcompent1
All-Star
32994 Points
8509 Posts
Moderator
Re: Running a console app from a web form
Apr 10, 2012 07:15 PM|LINK
If the console application is outside the web root, you're either going to have to hard code the path or you'll need to create a web folder that points at the console apps home folder.
wsyeager36
Member
385 Points
458 Posts
Re: Running a console app from a web form
Apr 11, 2012 12:55 PM|LINK
Bill Yeager
MCP.Net, BCIP
bbcompent1
All-Star
32994 Points
8509 Posts
Moderator
Re: Running a console app from a web form
Apr 11, 2012 01:00 PM|LINK
I think process.start acts like an independent process but just to be sure I would suggest testing it. To be honest, I haven't tested process.start that way.
wsyeager36
Member
385 Points
458 Posts
Re: Running a console app from a web form
Apr 13, 2012 04:44 PM|LINK
I don't suppose that there is a way to pass something back to the web application signifying that the console process has finished executing???
Bill Yeager
MCP.Net, BCIP