gpt4 book ai didi

.net - WebRequest.Create 抛出 "Value cannot be null. Parameter name: str"异常

转载 作者:行者123 更新时间:2023-12-02 04:18:08 24 4
gpt4 key购买 nike

我用构造函数围绕 HttpWebRequest 编写了一个包装器:

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


当我传递一个在 IE 中有效的 url 时:

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



我得到

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 requestUriString)



这是为什么 ?我如何解决它 ?

最佳答案

取消转义网址,然后重试。

关于.net - WebRequest.Create 抛出 "Value cannot be null. Parameter name: str"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1497607/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com