Prompt file download

前端 未结 5 1864
一生所求
一生所求 2020-12-11 14:39

I have a link on my page on click of which I am trying to generate a PDF document and then show the \"Open - Save\" prompt on the browser.

My HTML (reactjs component

5条回答
  •  半阙折子戏
    2020-12-11 15:36

    Create Content Disposition and add it to your response header

    var cd = new System.Net.Mime.ContentDisposition
    {
        // for example foo.bak
        FileName = System.IO.Path.GetFileName(fileName),
        // always prompt the user for downloading, set to true if you want 
        // the browser to try to show the file inline
        Inline = false,
    };
    Response.AppendHeader("Content-Disposition", cd.ToString());
    

提交回复
热议问题