none
How to start a new process in an asp.net web application RRS feed

  • Question

  • The default browser on our web servers is IE. We have a requirement to launch an instance of Chrome on a button click on our web apps.

    I have written an asp.net test app to try to achieve the above. In the test app I start a process on a button click on the server side to launch Chrome, but the Chrome window does not appear. The process seems to start fine as I get the the process ID and HasExited property is false. However, nothing comes up on screen and I don't seem to be able to find the process in the list of processes.

    I know that in a web app, a process starts in the context of the asp.net worker process and that it does not have access to the desktop and has restricted permissions. So I gave the IIS Admin Service process permission to interact with desktop on my local machine (via Processes window). Also, in the code I tried starting the process using my own user account which has admin access to the local machine but still could not get the Chrome window to appear on screen.

    My server side code is as follows:

    var psi = new ProcessStartInfo
    {
        FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
        Arguments = "http://www.msn.com",
        CreateNoWindow = false,
        UseShellExecute = true
        UserName = "username",
        Password = "secure password",
        Domain = "domain"
    };
    var process = new Process
    {
        StartInfo = psi
    };
    var result = process.Start(); // result is true
    int processId = process.Id; // processId is valid
    I would appreciate your help.



    • Edited by seemorgh Tuesday, October 15, 2019 2:28 PM
    Tuesday, October 15, 2019 2:10 PM

All replies

  • Have you gone into developer tools to see if there are any errors reported?

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, October 15, 2019 2:36 PM
    Moderator
  • Documentation and some articles mention that this is an obsolete feature. A service cannot interact directly with user in modern Windows.

    One of the mentioned solutions is to develop a regular helper application that is started automatically or manually, does not display a window, but waits for notifications from Web Service. Then it will be able to start the browser.

    The simple interaction between Web Service and helper application can be based on named events (EventWaitHandle).

    • Edited by Viorel_MVP Tuesday, October 15, 2019 3:42 PM
    Tuesday, October 15, 2019 3:41 PM
  • This is kind of an odd request.  Your code is always going to start Chrome on the server, but the request is coming from a web page that's running in a browser on a client.  Unless the client and the server are the same machine, the client user will never see the Chrome window.  Further, if the client and the server ARE the same machine, then you already have access to a browser.  Otherwise, you couldn't have sent the request.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Tuesday, October 15, 2019 5:09 PM