Raheel Khan
Raheel Khan

Reputation: 14777

Download a file that is written to the Response stream in ASP .NET C#

The objective: - Server side: Write a file to the response stream after verifying credentials. In other words, no public access to the file. - Client side: Download this file by from http://xyz.com?credentials=abc

So far, the ASPX page does the following:

What is the best way to download this file data from a WinForms app?

Upvotes: 1

Views: 1623

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1499750

The simplest approach would be to use WebClient:

WebClient wc = new WebClient();
wc.DownloadFile(url, filename);

(Either start this not in the UI thread, or use the async version. You don't want your UI thread to block while downloading.)

Upvotes: 4

Related Questions