2012-06-03 4 views
7

Ho un problema strano accedendo al seguente url:HttpWebRequest fallisce l'accesso ai http://xn--fanbys-exa.org/episodes.m4a.rss

http://xn--fanbys-exa.org/episodes.m4a.rss


Qui è il codice:

void WebRequestButton_Click(object sender, RoutedEventArgs e) 
    { 
     string url = "http://xn--fanbys-exa.org/episodes.m4a.rss"; 

     if (Uri.IsWellFormedUriString(url, UriKind.Absolute)) 
     { 
      HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(url); 
      if (webRequest != null) 
      { 
       webRequest.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), webRequest); 
      } 
     } 
    } 

    private void ReadWebRequestCallback(IAsyncResult callbackResult) 
    { 
     HttpWebRequest request = (HttpWebRequest)callbackResult.AsyncState; 
     HttpWebResponse response = null; 

     try 
     { 
      response = (HttpWebResponse)request.EndGetResponse(callbackResult); 
     } 
     catch (Exception e) 
     { 
      System.Diagnostics.Debug.WriteLine(e); 
     } 

     if (response != null) 
     { 
      using (StreamReader httpwebStreamReader = new StreamReader(response.GetResponseStream())) 
      { 
       string results = httpwebStreamReader.ReadToEnd(); 
       System.Diagnostics.Debug.WriteLine(results); 
      } 

      response.Close(); 
     } 
    } 


Leggendo la risposta con request.EndGetResponse() genera questa eccezione:

A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll 
System.ArgumentException ---> System.ArgumentException: The parameter is incorrect. 
    at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
    at MS.Internal.XcpImports.WebRequest_Send(InternalWebRequest request) 
    at MS.Internal.InternalWebRequest.Send() 
    at System.Net.Browser.ClientHttpWebRequest.PrepareAndSendRequest(String method, Uri requestUri, Stream requestBodyStream, WebHeaderCollection headerCollection, CookieContainer cookieContainer) 
    at System.Net.Browser.ClientHttpWebRequest.BeginGetResponseImplementation() 
    at System.Net.Browser.ClientHttpWebRequest.InternalBeginGetResponse(AsyncCallback callback, Object state) 
    at System.Net.Browser.ClientHttpWebRequest.BeginGetResponse(Async'UI Task' (Managed): Loaded 'System.Runtime.Serialization.dll' 


Per quanto posso dire l'url

http://xn--fanbys-exa.org/episodes.m4a.rss

è wellformed.
Tutti i browser che ho provato possono gestirlo.

I test con Fiddler mostrano che nessuna richiesta HTTP viene inviata dall'emulatore di Windows Phone.

Se hanno provato diversi URL (con un'istanza Fiddler attivo):

string url = "http://xn--fanbys-exa.org/episodes.m4a.rss"; 
    // not ok --> System.ArgumentException: The parameter is incorrect. 

string url = "http://xn--fanbys-exa.org"; 
    // not ok --> System.ArgumentException: The parameter is incorrect. 

string url = Uri.EscapeUriString("http://xn--fanbys-exa.org/episodes.m4a.rss"); 
    // not ok --> System.ArgumentException: The parameter is incorrect. 

string url = "http://stackoverflow.com";   
    // ok, HTTP request is sent and response is received 

string url = "http://stack--overflow.com";  
    // ok, HTTP request is sent and response is received 

string url = "http://xn--stackoverflow.com";  
    // ok, HTTP request is sent and response 502 is received 
    // --> System.Net.WebException: The remote server returned an error: NotFound. 

Il problema può essere riprodotto con l'emulatore e sul dispositivo.
La mia ipotesi è che questo potrebbe essere correlato al DNS.
Non ho alcun controllo sul sito web di riferimento e sulla sua voce DNS.

Qualche idea?

+0

deciso di provarlo ed è in effetti qualcosa di strano. Il codice funziona come un incantesimo usando qualsiasi URL fornito ad eccezione di quelli nel dominio fanbóys.org. –

risposta

0

Sì, posso verificare anche il problema e inoltre non vedo traffico nel violinista. Errore più strano mai!

string url = "http://a--b-c.org"; - Fine 
    string url = "http://xn--fanbys-exa.org"; - Error 
    string url = "http://xn--2fanbys-exa.org"; - Error 
    string url = "http://xn--fanbys2-exa.org"; - Error 
    string url = "http://xn--fan2bys-exa.org"; - Error 
    string url = "http://xn-fanbys-exa.org"; - Fine 
    string url = "http://xn--b-exa.org"; - Fine 
    string url = "http://xn--f.org"; - Fine 
    string url = "http://a--fanbys-exa.org"; - Fine 
    string url = "http://xn--fanbys-c.org"; - Fine 
    string url = "http://xn--fanbys-exa2.org"; - Fine 
    string url = "http://2xn--fanbys-exa.org"; - Fine 
    string url = "http://xn--f-exa.org"; - Fine 
    string url = "http://xn--fs-exa.org"; - Error 
    string url = "http://x--fs-exa.org"; - Fine 
    string url = "http://xn--fs.org"; - Fine 
    string url = "http://xn--fs-.org"; - Fine 
    string url = "http://xn--fs-e.org"; - Fine 
    string url = "http://xn--fs-ea.org"; - Fine 
    string url = "http://xn--fs-ex.org"; - Fine 
    string url = "http://xn--fs-exx.org"; - Error 
    string url = "http://xn--fs-eee.org"; - Error 
    string url = "http://aa--aa-aaa.org"; - Fine 
    string url = "http://aa--aa-eee.org"; - Fine 
    string url = "http://xa--aa-eee.org"; - Fine 
    string url = "http://xa--fs-eee.org"; - Fine 
    string url = "http://zn--fs-eee.org"; - Fine 
    string url = "http://xn--fa-eee.org"; - Error 
    string url = "http://xn--faa-eee.org"; - Error 
    string url = "http://xn--faaaaaaaaaaaaa-eee.org"; - Error 
    string url = "http://xn--faaaaaaaaaaaaaeee.org"; - Fine 

È interessante notare che l'eccezione si è già verificato prima di 'EndGetResponse' - se si guarda in '_exception' campo privato appena prima 'EndGetResponse' viene chiamato.

sorprende, WebClient mostra anche un problema simile:

 const string url = "http://xn--fanbys-exa.org/episodes.m4a.rss"; 

     var wc = new WebClient(); 
     wc.DownloadStringCompleted += (o, args) => 
              { 
               Debug.WriteLine(args.Result); 
              }; 

     wc.DownloadStringAsync(new Uri(url, UriKind.Absolute)); 

rendimenti:

System.Net.WebException was unhandled 
    Message=An exception occurred during a WebClient request. 
    StackTrace: 
     at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() 
     at System.Net.DownloadStringCompletedEventArgs.get_Result() 
     at OddballHttp.MainPage.<MainPage_Loaded>b__0(Object o, DownloadStringCompletedEventArgs args) 
     at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) 
     at System.Net.WebClient.DownloadStringOperationCompleted(Object arg) 
     at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) 
     at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) 
     at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) 
     at System.Delegate.DynamicInvokeOne(Object[] args) 
     at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) 
     at System.Delegate.DynamicInvoke(Object[] args) 
     at System.Windows.Threading.DispatcherOperation.Invoke() 
     at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority) 
     at System.Windows.Threading.Dispatcher.OnInvoke(Object context) 
     at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args) 
     at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args) 
     at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult) 
    InnerException: System.ArgumentException 
     Message="" 
     StackTrace: 
       at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) 
       at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) 
       at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result) 
       at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result) 
       at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object state2) 
       at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state) 
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
       at System.Threading.ThreadPool.WorkItem.doWork(Object o) 
       at System.Threading.Timer.ring() 
     InnerException: System.ArgumentException 
       Message=The parameter is incorrect. 
       StackTrace: 
        at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
        at MS.Internal.XcpImports.WebRequest_Send(InternalWebRequest request) 
        at MS.Internal.InternalWebRequest.Send() 
        at System.Net.Browser.ClientHttpWebRequest.PrepareAndSendRequest(String method, Uri requestUri, Stream requestBodyStream, WebHeaderCollection headerCollection, CookieContainer cookieContainer) 
        at System.Net.Browser.ClientHttpWebRequest.BeginGetResponseImplementation() 
        at System.Net.Browser.ClientHttpWebRequest.InternalBeginGetResponse(AsyncCallback callback, Object state) 
        at System.Net.Browser.ClientHttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state) 
        at System.Net.WebClient.DownloadBits(WebRequest request, Stream writeStream, CompletionDelegate completionDelegate, AsyncOperation asyncOp) 
        at System.Net.WebClient.DownloadStringAsync(Uri address, Object userToken) 
        at System.Net.WebClient.DownloadStringAsync(Uri address) 
        at OddballHttp.MainPage.MainPage_Loaded(Object sender, RoutedEventArgs e) 
        at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) 
        at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)