proprio per lo shock del tamponamento chiedevo, mica mettevo in dubbio la tua capacita' di coder


comunque, io ho fatto un bottone con il suo click, e funziona. Framework 4.0, visual studio 2017:

ASPX:

codice:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Download_Forzato.aspx.cs" Inherits="STUDIO3._0.Forum_HTML.Download_Forzato" %>


<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Button ID="bt" Text="scarica il file" runat="server" OnClick="bt_Click" />
        </div>
    </form>
</body>
</html>


C#:

codice:
public partial class Download_Forzato : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
             // vuoto
        }


        protected void bt_Click(object sender, EventArgs e)
        {
            Response.Expires = -1;


            String strPath = Server.MapPath("file_download.txt");
            System.IO.FileInfo file = new System.IO.FileInfo(strPath);


            if(file.Exists)
            {
                Response.Clear();
                Response.AddHeader("Content-Disposition", "attachment; filename='" + file.Name + "'");
                Response.AddHeader("Content-Length", file.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.TransmitFile(strPath);
                Response.End();
             }
            else
            {
                Response.Write("Impossibile scaricare il file.");
            }
        }
    }
mi fa scaricare il file "file_download.txt" presente nella stessa cartella