使用System.Net.WebRequest获取无效的uri [英] Getting invalid uri with System.Net.WebRequest
问题描述
在网页浏览器中实际加载网站之前,编写一个测试网站响应的脚本。 使用上面的类方法,当我没有"http://"时,我收到以下错误在"www.xxxxx"之前网站部分:
异常调用"创建"用"1"表示"1"。参数:"无效的URI:无法确定URI的格式。"
在Desktop\Scripts\function.ps1:39 char:48
+ $ HTTP_Request = [System.Net.WebRequest] :: Create(" $ b")
但是当我在其中添加http时会验证该网站。 我的理解是http通常会附加到系统中的网站请求中吗?
有什么想法吗?我错过了什么吗?
谢谢大家。
JCtech1123,干杯
你的意思是什么?"http通常总是附加到系统内的网站请求"?什么是"系统"?
来自文档:
https://msdn.microsoft.com/en-us/library/0aa3d588%28v=vs.110%29.aspx".NET Framework包括对
http:// , https:// , ftp:// 的支持和 file:// URI方案。",因此您必须在URi中提供正确的协议,以便Create方法能够知道该怎么做。
Writing a script that tests the response to a website before actually loading it in web browser. Using the class method above I am getting the following error when I don't have "http://" before the "www.xxxxx" part in site:
Exception calling "Create" with "1" argument(s): "Invalid URI: Theformat of the URI could not be determined."
At Desktop\Scripts\function.ps1:39 char:48
+ $HTTP_Request = [System.Net.WebRequest]::Create ("$b")
However when I do add the http in it verifies the site. My understanding is that http is usually always appended to a site request within the system?
Any thoughts? Am I missing something?
thanks all.
JCtech1123, Cheers
What do you mean by "http is usually always appended to a site request within the system"? What is "the system"?
From the documentation: https://msdn.microsoft.com/en-us/library/0aa3d588%28v=vs.110%29.aspx "the .NET Framework includes support for the http://, https://, ftp://, and file:// URI schemes.", so you must provide the correct protocol in the URi for the Create method to be able to know what to do.
这篇关于使用System.Net.WebRequest获取无效的uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!