A
Android Question
Guest
I have a web project in asp.net and it is running on android devices. The site contains more contents and user can download them. Now user can only see the image displayed when clicking on download but i need to change this and make the download start when user clicks on download.
For this i used a custom header specifying that the file is an attachment and it works but ...on android the issue is that it calls the aspx page twice.
Here is my code:
Response.Cache.SetCacheability(HttpCacheability.Private, "Community=DEV");
// dwldUrl = (string)(Session["dwldUrl"]);
var webClient = new WebClient();
Trace.Warn(dwldUrl);
byte[] imageBytes = webClient.DownloadData("url");
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.BufferOutput = true;
Response.Buffer = false;
Response.AddHeader("Content-Length", imageBytes.Length.ToString());
Response.AppendHeader("Content-Disposition", "inline;filename=image.jpg");
// Response.BinaryWrite(binaryData);
Response.OutputStream.Write(imageBytes, 0, imageBytes.Length);
Response.End();
And the scenario is the following :
User clicks on download and the two options are displayed (aspx page is called for the first time)
User choses to download(aspx page is called for the second time).
User choses to open in gallery (aspx page not being called).
And if i change inline with attachment the download starts directly and the trace shows that aspx page has been called twice.
Thanks for any hint!
For this i used a custom header specifying that the file is an attachment and it works but ...on android the issue is that it calls the aspx page twice.
Here is my code:
Response.Cache.SetCacheability(HttpCacheability.Private, "Community=DEV");
// dwldUrl = (string)(Session["dwldUrl"]);
var webClient = new WebClient();
Trace.Warn(dwldUrl);
byte[] imageBytes = webClient.DownloadData("url");
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.BufferOutput = true;
Response.Buffer = false;
Response.AddHeader("Content-Length", imageBytes.Length.ToString());
Response.AppendHeader("Content-Disposition", "inline;filename=image.jpg");
// Response.BinaryWrite(binaryData);
Response.OutputStream.Write(imageBytes, 0, imageBytes.Length);
Response.End();
And the scenario is the following :
User clicks on download and the two options are displayed (aspx page is called for the first time)
User choses to download(aspx page is called for the second time).
User choses to open in gallery (aspx page not being called).
And if i change inline with attachment the download starts directly and the trace shows that aspx page has been called twice.
Thanks for any hint!