I have a HttpWebRequest
that is currently downloading the file but I want to stop it downloading and save the file in a folder instead.
webRequest.Method = "GET";
webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.ContentType = "text/xml;charset=UTF-8";
using (var webResponse = webRequest.GetResponse())
using (var webStream = webResponse.GetResponseStream())
{
if (webStream != null)
{
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=\"test.pdf\"");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
webStream.CopyTo(Response.OutputStream);
Response.Flush();
Response.End();
}
}
I have tried changing the ContactType to Response.ContentType = "application/x-download";
and adding Response.TransmitFile
but the file still downloads.