简体   繁体   English

WebRequest.Create抛出“Value不能为null。 参数名称:str“exception

[英]WebRequest.Create throws “Value cannot be null. Parameter name: str” exception

I wrote a wrapper around HttpWebRequest with the constructor : 我用构造函数编写了一个围绕HttpWebRequest的包装器:

  public MyHttpRequest(string requestUrl) { this.webRequest = (HttpWebRequest)WebRequest.Create(requestUrl); } 

when I pass a vaild url that works in IE : 当我传递一个在IE中工作的虚拟网址:

http://www.google.co.il/search?q=%D7%A9%D7%9E%D7%A8+%D7%97%D7%A1%D7%95%D7%9F&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a http://www.google.co.il/search?q=%D7%A9%D7%9E%D7%A8+%D7%97%D7%A1%D7%95%D7%9F&ie=utf-8&oe=utf -8水性= T&RLS = org.mozilla:EN-US:官方与客户端= firefox的-A

I get 我明白了

System.ArgumentNullException occurred Message="Value cannot be null.\\r\\nParameter name: str" Source="mscorlib" ParamName="str" StackTrace: at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str) at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) at System.Uri.ParseConfigFile(String file, IdnScopeFromConfig& idnStateConfig, IriParsingFromConfig& iriParsingConfig) at System.Uri.GetConfig(UriIdnScope& idnScope, Boolean& iriParsing) at System.Uri.InitializeUriConfig() at System.Uri.InitializeUri(ParsingError err, UriKind uriKind, UriFormatException& e) at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at System.Uri..ctor(String uriString) at System.Net.WebRequest.Create(String requ System.ArgumentNullException发生Message =“Value不能为null。\\ r \\ nParameter name:str”Source =“mscorlib”ParamName =“str”StackTrace:at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String [] str)at System .Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess访问,AccessControlActions控件,String [] pathListOrig,布尔checkForDuplicates,Boolean needFullPath,Boolean copyPathList)位于System的System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess访问,字符串路径)。 System.Uri.InitializeUri的System.Uri.InitializeUriConfig()中的System.Uri.GetConfig(UriIdnScope&idnScope,Boolean&iriParsing)中的Uri.ParseConfigFile(String file,IdnScopeFromConfig&idnStateConfig,IriParsingFromConfig&iriParsingConfig)(ParsingError err,UriKind uriKind,UriFormatException&e) System.Uri.CreateThis(String uri,Boolean dontEscape,UriKind uriKind)at System.Uri..ctor(String uriString)at System.Net.WebRequest.Create(String requ) estUriString) estUriString)

Why is that ? 这是为什么 ? how do i fix it ? 我如何解决它 ?

Unescape网址,然后再试一次。

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

相关问题 SignedXml.CheckSignature抛出异常:值不能为null。 参数名称:名称 - SignedXml.CheckSignature throws exception: Value cannot be null. Parameter name: name 值不能是 null。 参数名称:dest - Value cannot be null. Parameter name: dest 值不能为null。 参数名称路径 - value cannot be null. parameter name path Image.Save() 抛出异常“值不能为空。/r/n 参数名称:编码器” - Image.Save() throws exception "Value cannot be null./r/nParameter name: encoder" 'Protexis。׋'的类型初始值设定项引发了异常。 值不能为空。 参数名称:path1 - The type initializer for 'Protexis.׋' threw an exception. Value cannot be null. Parameter name: path1 System.ArgumentNullException:值不能为null。 参数名称:ownerType - System.ArgumentNullException: Value cannot be null. Parameter name: ownerType System.ArgumentNullException: '值不能为空。 参数名称:items' - System.ArgumentNullException: 'Value cannot be null. Parameter name: items' Azure 函数:值不能为空。 参数名称:来源 - Azure function: Value cannot be null. Parameter name: source C#,WebRequest.Create(String URI)返回null - C#, WebRequest.Create(String URI) returns null 值不能是 null。(参数“值”) - Value cannot be null. (Parameter 'value')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM