Quantcast
Channel: How to download a file using ASP.NET - Stack Overflow
Viewing all articles
Browse latest Browse all 4

How to download a file using ASP.NET

$
0
0

In the below code i want to download a file from local when i click link button it should download a file from specific path. In my case it throws

'C:/Search/SVGS/Documents/img.txt' is a physical path, but a virtual path was expected.

protected void lnkbtndoc_Click(object sender, EventArgs e){    LinkButton lnkbtndoc = new LinkButton();    var SearchDoc = Session["Filepath"];    string file = SearchDoc.ToString();    Response.AddHeader("Content-Disposition", "attachment;filename=\""+ file +"\"");    Response.TransmitFile(Server.MapPath(file));    Response.End();}

Viewing all articles
Browse latest Browse all 4

Trending Articles