4

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:en-US:official&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 ?

Gady
  • 1,514
  • 2
  • 16
  • 32
  • 1
    Which version of the .NET Framework did this occur on? I tried it with v3.5, and it did not give me the exception. – feroze Sep 30 '09 at 15:57
  • This looks like a bug. Can you post thiss question on the Microsoft NCL support group (http://social.msdn.microsoft.com/forums/en-us/ncl) – feroze Oct 01 '09 at 23:09
  • .NET 3.5 i submitted the post to MS NCL – Gady Oct 21 '09 at 15:59

1 Answers1

1

Unescape the url, then try again.

leppie
  • 115,091
  • 17
  • 196
  • 297