Z
zequion1
Guest
I'm trying to download a file "download.txt" from my website. When using Http.WebClient instead of returning the file, it returns a page html by default. If I entered the url in a browser, the file "download.txt" appears correctly on the screen.
I have tested these systems and they all return the html page.
System.Net.WebClient MyWebClient = new System.Net.WebClient();
System.Uri MyUri = new System.Uri("http://www.MyWeb.org/data/Web Downloads/download.txt");
// Download. Test.
MyWebClient.DownloadString(MyUri.ToString());
// Download. Test.
MyWebClient.DownloadFile(MyUri.ToString(), @"F:\Temp\download.txt");
// Download. Async. Execute.
MyWebClient.DownloadDataAsync(MyUri);
Result:
" \n <html>\n<head>\n<meta http-equiv=\"pragma\" content=\"no-cache\">\n<meta http-equiv=\"cache-control\" content=\"no-cache\">\n<meta http-equiv=\"content-language\" content=\"es\">\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n<title>My Web</title>\n<meta name=\"description\" content=\"aplications in .Net.\">\n<meta name=\"keywords\" content=\"search\">\n<meta name=\"robots\" content=\"index, follow\">\n<meta name=\"revisit-after\" content=\"15 days\">\n</head>\n<FRAMESET ROWS=\"0,*\" COLS=\"*\" BORDER=\"0\">\n\t<FRAME SRC=\"\" NAME=\"top\">\n\t<FRAME SRC=\" http://www.MyWeb.org/data/Web Downloads/download.txt\" NAME=\"main\">\n</FRAMESET>\n<body>\n<P>You are seeing this message because your browser does not support frames.</P>\n<P><a href=\"http://www.MyWeb.org/data/Web Downloads/download.txt\">Visit the appropriate destination page</A></P>\n\n</body>\n</html> \n \n \n \n \n"
Continue reading...
I have tested these systems and they all return the html page.
System.Net.WebClient MyWebClient = new System.Net.WebClient();
System.Uri MyUri = new System.Uri("http://www.MyWeb.org/data/Web Downloads/download.txt");
// Download. Test.
MyWebClient.DownloadString(MyUri.ToString());
// Download. Test.
MyWebClient.DownloadFile(MyUri.ToString(), @"F:\Temp\download.txt");
// Download. Async. Execute.
MyWebClient.DownloadDataAsync(MyUri);
Result:
" \n <html>\n<head>\n<meta http-equiv=\"pragma\" content=\"no-cache\">\n<meta http-equiv=\"cache-control\" content=\"no-cache\">\n<meta http-equiv=\"content-language\" content=\"es\">\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n<title>My Web</title>\n<meta name=\"description\" content=\"aplications in .Net.\">\n<meta name=\"keywords\" content=\"search\">\n<meta name=\"robots\" content=\"index, follow\">\n<meta name=\"revisit-after\" content=\"15 days\">\n</head>\n<FRAMESET ROWS=\"0,*\" COLS=\"*\" BORDER=\"0\">\n\t<FRAME SRC=\"\" NAME=\"top\">\n\t<FRAME SRC=\" http://www.MyWeb.org/data/Web Downloads/download.txt\" NAME=\"main\">\n</FRAMESET>\n<body>\n<P>You are seeing this message because your browser does not support frames.</P>\n<P><a href=\"http://www.MyWeb.org/data/Web Downloads/download.txt\">Visit the appropriate destination page</A></P>\n\n</body>\n</html> \n \n \n \n \n"
Continue reading...