views:

726

answers:

1

Hi I wrote a wrapper around HttpWebRequest with the constructor :

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

when I pass a vaild url that works in 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%3Aen-US%3Aofficial&client=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 requestUriString)

Why is that ? how do i fix it ?

+1  A: 

Unescape the url, then try again.

leppie