单击链接按钮时,这是我的代码:
protected void btnDownload_OnClick(object sender, EventArgs e)
{
string url = "https://ppespcollab.amat.com/sites/IMDb/Shared Documents/LatestTest_IMDb_LPDetails_Template.xlsx";
string file_name = Server.MapPath(".") + "\\Sample.xlsx"; ;
WebClient webClient = new WebClient();
webClient.UseDefaultCredentials = true;
webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
webClient.DownloadFile(url, @file_name);
webClient.Dispose();
}
没有显示错误。但它不下载。我很无能为力。试过不同的方式。什么都行不通。