简体   繁体   English

webclient用于向服务器发出请求但返回ERROR

[英]webclient used to make a request to server but returns ERROR

Using a WebClient to make a request to the server. 使用WebClient向服务器发出请求。

WebClient web = new WebClient();
string xmlString = web.DownloadString(partialUrl);

The partialUrl returns a valid URL, which if I use in a browser returns the correct XML list, but if ran from debug mode in Visual Studio it throws the error: 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)

From Your Error It seems that you are creating a web request with wrong url. 来自您的错误您似乎正在使用错误的网址创建网络请求。

Please make sure that in web.DownloadString(partialUrl); 请确保在web.DownloadString(partialUrl); url string must start with proper protocol like (http,https etc.) url字符串必须以适当的协议开始,如(http,https等)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM