suppress save/dialog in web browser and automate the download

后端 未结 1 1877
臣服心动
臣服心动 2021-01-25 21:21

I want to automate the download of an exe prompted from a link from the client side. I can get the first redirected link from http://go.microsoft.com/fwlink/?LinkID=149156 to ht

相关标签:
1条回答
  • 2021-01-25 21:42

    Just tested this out and it will download the file.

    WebClient client = new WebClient();
    
    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
    
    client.DownloadFile(url, "Filename.exe");
    

    You just needed to add the user-agent as the particular silverlight download depends on what browser you are running on, hence if it can't detect one then it will fail.

    Change the user-agent to something that will trigger the appropriate download you want.

    0 讨论(0)
提交回复
热议问题