0

When I try to launch my console application from my web application on my local machine it works perfect, but when I try to do it on hosting server after publish I get "Access is denied" error.

This is the code where I call the console application, in case of that if you want.

      try
            {
                ProcessStartInfo startinfo = new ProcessStartInfo();
                startinfo.FileName = Server.MapPath("~/ConsoleApplications/WebConsol.exe");
                startinfo.CreateNoWindow = true;
                startinfo.UseShellExecute = true;
                Process myProcess = Process.Start(startinfo);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                if (ex.InnerException != null)
                {
                    Response.Write(ex.InnerException);
                }
            }

How can I give permission to the console application in order to avoid "Access is denied" error? Do I need to to it in my project or is it about web hosting server?

Note: I want to launch the console application to use as TCP server to implement a tcp listener.

Edit: My hosting provider is Arvixe.

zgrkpnr89
  • 325
  • 1
  • 6
  • 17
  • 1
    Why do you need to launch a console window from your web application? What are you trying to do by doing that? It could be a trust issue; who's your provider? – George Stocker Jul 31 '15 at 11:19
  • @GeorgeStocker I will add them in my question as details. – zgrkpnr89 Jul 31 '15 at 11:22
  • ask the provider if it is allowed to do that. should you succeed you may discover that the server is accessible only on port 80/443 (not unusual) so your listener cannot be reached. also your account may be terminated if this behaviour is not supported and/or explicitly forbidden. – Paolo Jul 31 '15 at 12:31

2 Answers2

1

As mention in another answer, you should add these lines of code:

startinfo.UserName = username;
startinfo.Password = MakeSecureString(password);

plus:

startinfo.UserShellExecute = false;

You can get more information here:

  1. Link1
  2. Link2
Community
  • 1
  • 1
0

Do you have enough privilege in the hosting environment to run such application?

If you do, try setting the username and password of account who has privilege to execute it:

startinfo.UserName = username;
startinfo.Password = MakeSecureString(password);
Alan Tsai
  • 2,465
  • 1
  • 13
  • 16