我尝试了几种方法来下载在此(http://187.72.229.145/esiat/Valida_NFE_Emissao.aspx?InscricaoMunicipal=0032161&NumeroNota=15&CodVrfNfe=TWU7UO47QG)ASPX页面中生成的PDF,但却无法下载。
我尝试WebClient,WebRequest ..等等。 知道如何在c#e .net 3.5 ???
中做到这一点例如:
private void button1_Click(object sender, EventArgs e)
{
string url = "http://187.72.229.145/esiat/Valida_NFE_Emissao.aspx?InscricaoMunicipal=0032161&NumeroNota=15&CodVrfNfe=TWU7UO47QG";
string fileName = "pdf.pdf";
WebClient webClient = new WebClient();
webClient.DownloadFile(url, fileName);
}
答案 0 :(得分:0)
您可能需要使用代理,添加以下行:
webClient.Proxy = new WebProxy("192.168.1.5", 3128); // <- Proxy address & port
webClient.DownloadFile(url, fileName);
最好使用文件名的绝对路径。
答案 1 :(得分:0)
我改变了WebClient的形状,它起作用了!
private void button1_Click(object sender, EventArgs e)
{
string url = "http://187.72.229.145/esiat/Valida_NFE_Emissao.aspx?InscricaoMunicipal=0032161&NumeroNota=15&CodVrfNfe=TWU7UO47QG";
string fileName = "pdf.pdf";
WebClient webClient = new WebClient();
webClient.DownloadFileAsync(new Uri(url, UriKind.Absolute), fileName);
}