WPF:无效的URI:无法确定URI的格式

时间:2012-05-31 07:13:00

标签: wpf http https uri

我想得到你管视频信息。所以我准备了网址并将其称为以下

String YouTubeVideoInfo = "www.youtube.com/get_video_info?video_id=" + FinalVideoId;

                **WebRequest HttpWReq = (WebRequest)WebRequest.Create(YouTubeVideoInfo);**
                WebResponse HttpWResp = (WebResponse)HttpWReq.GetResponse();
                Stream stream = HttpWResp.GetResponseStream();
                StreamReader reader = new StreamReader(stream);
                string contents = reader.ReadToEnd();

但是上面的代码给出了错误。所以我只想知道是否有任何方法可以在不添加协议(http,https)

的情况下调用此URL

1 个答案:

答案 0 :(得分:3)

不,你不能。如果你不给它一个URI,WebRequest如何知道协议?因为它确实缺少协议部分,因此你不能将它作为URI传递给任何需要它的东西。