0

我正在 Window 7 中使用 C#.NET 开发一个 Window 应用程序。该应用程序从 URL 读取 Web 服务器内容。当我尝试这样做时,出现以下异常:

错误:uri 的格式无法确定具有 System.UriFormatException。

这是我的代码:

StreamReader instream; 
WebRequest webrequest; 
WebResponse webresponse;
webrequest = WebRequest.Create(textBox1.Text);
webresponse = webrequest.GetResponse();
instream = new StreamReader(webresponse.GetResponseStream());
textBox2.Text = instream.ReadToEnd();
4

2 回答 2

0

利用

Uri myUri = new Uri(textBox1.Text);    
webrequest = WebRequest.Create(myUri ); 
于 2012-09-13T12:24:44.683 回答
0

Fix your input string. It is likely missing the protocol (http, https, ftp, etc) or is malformed in some other way.

于 2012-09-13T12:35:55.053 回答