title: Downloading a file from url that triggers save dialog
body: <p>I am trying to automate downloading of some files by automating Internet Exporer.</p>
  <p>The code works in that it can click the download button (iframe inside an iframe) which then triggers a save dialog.</p>
  <p>To get around the save dialog popping up in IE, I have inspected the download button and retrieved the address, which is:</p>
  <p><code>&quot;https://.../Shared/RepositoryFileServer.ashx?fileId=7129415&amp;Type=Attachment&quot;</code></p>
  <p>There are a couple of points to note about this url:</p>
  <ol>
  <li>If I run this url inside the &quot;automated&quot; explorer window, the save dialog displays and I can download the file</li>
  <li>If I run this url in a new explorer window, it doesn't work, it's as if it uses cookies or a session (I don't have the knowledge to know about what happens in the background).</li>
  </ol>
  <p>Running this code:</p>
  <pre><code>WebClient client = new WebClient();
  client.DownloadFile(link, fullPath);
  </code></pre>
  <p>creates a file, but is corrupted and I suspect it is because of point 2 above i.e. this isn't using the current session.</p>
  <p>My question then is, if I could somehow access the same session, would DownloadFile work on this link? I ask because this link isn't a &quot;direct&quot; link to the file, something like <code>https://.../Shared/Repository/file.xlsx</code> because it is being generated in the background.</p>
  <p>For my automation I am using <code>InternetExplorerMedium</code>. I won't paste the code here as this part works great.</p>
  <p>One caveat to this is that I am building this in a large financial institution, and practically air walled off, so I cannot download any extension such as selenium etc, I just have to use stock .net 4.7.</p>
  <p>Any direction or ideas would be greatly appreciated.</p>