我一直在尝试编写一个代码来从服务器下载文件,路径是正确的,但单击它时文件没有下载。
删除代码正常工作,如下所示:
protected void DeleteFile(object sender, EventArgs e)
{
string filePath = (sender as LinkButton).CommandArgument;
File.Delete(filePath);
GenerateDownloadLinks();
}
但是下载没有开始下载(调试在整个代码中运行):
protected void ButtonDownload_Click(object sender, EventArgs e)
{
string path = (sender as LinkButton).CommandArgument;
string name = Path.GetFileName(path);
string ext = Path.GetExtension(path);
HttpResponse response = HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.AddHeader("content-disposition",
"attachment; filename=" + name);
response.ContentType = "text/plain";
response.TransmitFile(path);
response.Flush();
response.End();
}
我正在下载的文件是.dat文件。我尝试更改和添加配置,但没有运气
答案 0 :(得分:0)
问题是更新面板相关,我的datalist在更新面板中