Disable the client ie from downloading files through URL? Only files can be downloaded from the specified Download Page
Only requests transferred from this website can be downloaded. You can directly enter an address in the address bar and cannot download it.
1. Do not use links. Use the write-back stream method. Only click the page button to activate download.
Private void filedownload (string downpath)
{
String fullfilename = server. mappath (downpath );
Fileinfo downloadfile = new fileinfo (fullfilename );
Response. Clear ();
Response. clearheaders ();
Response. Buffer = false;
Response. contenttype = "application/octet-stream ";
Response. appendheader ("content-disposition", "attachment; filename =" + httputility. urlencode (downloadfile. fullname, system. Text. encoding. utf8 ));
Response. appendheader ("Content-Length", downloadfile. length. tostring ());
Response. writefile (downloadfile. fullname );
Response. Flush ();
Response. End ();
}
2. Add a hidden domain on the previous page. If the visitor copies the address string, the hidden parameters are not copied. Check the hidden parameters on the download page.
<HTML>
<Body>
<Form>
<Input id = "down" name = "down" type = "hidden" value = "down"/>
</Form>
</Body>
</Html>
Dowload page
If (reuquest ["down"] = NULL)
Return;