Download file and run it automatically immediately after download

Qamar, Mo 101 Reputation points
2022-04-04T16:59:57.05+00:00

How do I download a file and run it automatically immediately after download is completed?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
1,474 questions
ASP.NET Web Forms
ASP.NET Web Forms
A part of the ASP.NET web application framework that can be used to create ASP.NET web applications.
547 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Albert Kallal 3,801 Reputation points
    2022-04-04T17:30:56.987+00:00

    You can't do that anymore.

    At one time browsers did allow you to say click on a download link, and then choose run.

    but, these days, for reasons of security, it not really possible - and this ability is controlled by the browser settings, and not your asp.net web site code.

    It simply too high of a security risk. So, when you download a file?, then users will have to open their download folder, and choose run in most cases.


  2. Qamar, Mo 101 Reputation points
    2022-04-04T19:41:21.813+00:00

    I've got it to work... Here is the code.

                string toolsDir = System.Web.Hosting.HostingEnvironment.MapPath(ToolsDir);
                string toolexe = Path.Combine(toolsDir, ToolName);
                ProcessStartInfo psi = new ProcessStartInfo(toolexe);
                psi.WindowStyle = ProcessWindowStyle.Hidden;
                psi.CreateNoWindow = true;
                psi.Arguments = "-d:Dummy";
                Process p = Process.Start(psi);
    
    0 comments No comments

  3. AgaveJoe 22,626 Reputation points
    2022-04-04T19:53:06.167+00:00

    This design only works on your development machine because it is both the server and the client. Once deployed the code will execute on the server not the client machine.

    0 comments No comments