0
使用WebClient
向服務器發出請求。webclient用於向服務器發出請求,但返回ERROR
WebClient web = new WebClient();
string xmlString = web.DownloadString(partialUrl);
的partialUrl
返回一個有效的URL,這要是我在瀏覽器中使用返回正確的XML名單,但如果從在Visual Studio調試模式下運行它引發錯誤:
{System.Net.WebException: An exception occurred during a WebClient request. ---> System.NotSupportedException: The URI prefix is not recognized.
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(Uri requestUri)
at System.Net.WebClient.GetWebRequest(Uri address)
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
--- End of inner exception stack trace ---
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at System.Net.WebClient.DownloadString(String address)
at Synchroniser.XML.GalwayPortal.Download_POS(String partialUrl, IInterpreter interpreter)
啊非常好的謝謝你的幫助。 – John