I have download.aspx
page. In Page_Load
event i download file from url and Increase download count and store to database.
When i refresh page download count increased. if i deny to download count also increased.
I want to increase count when i save file from browser.
My code is as following
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string url = "http://localhost:5045/Documents/sample.pdf";
DownLoadFile(url);
//This is code for download counter do entry in database
SoftwareController.SoftwareDownloadHistoryEdit(0, Id, CommonController.GETMyIP(), false, "ADD");
}
}
protected void DownLoadFile(string URL)
{
System.Net.WebClient net = new System.Net.WebClient();
Response.ClearHeaders();
Response.Clear();
Response.Expires = 0;
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "Attachment;FileName=");
Response.ContentType = "APPLICATION/octet-stream";
Response.BinaryWrite(net.DownloadData(URL));
Response.End();
}