Windows phone 7 HttpWebRequest访问失败http://xn--fanbys-exa.org/episodes.m4a.rss

Windows phone 7 HttpWebRequest访问失败http://xn--fanbys-exa.org/episodes.m4a.rss,windows-phone-7,httpwebrequest,windows-phone-7.1,Windows Phone 7,Httpwebrequest,Windows Phone 7.1,我在访问以下url时遇到一个奇怪的问题: 代码如下: void WebRequestButton_Click( object sender, RoutedEventArgs e ) { string url = "http://xn--fanbys-exa.org/episodes.m4a.rss"; if ( Uri.IsWellFormedUriString( url, UriKind.Absolute ) ) {

我在访问以下url时遇到一个奇怪的问题:


代码如下:

    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( );
        }
    }

读取带有request.EndGetResponse()的响应会引发以下异常:

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'

据我所知,这个网址

结构合理。
我尝试的所有浏览器都可以处理它。

使用Fiddler进行测试表明,没有从Windows Phone emulator发送HTTP请求

如果您尝试了多个不同的URL(使用活动的Fiddler实例):

该问题可通过模拟器和设备再现。
我猜这可能与DNS有关。
我无法控制引用的网站及其DNS条目


有什么想法吗?

是的,我也可以验证这个问题,而且在fiddler中也看不到流量。有史以来最奇怪的错误

  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
有趣的是,异常已经发生在'EndGetResponse'之前——如果您在调用'EndGetResponse'之前查看私有字段'\u exception'

毫不奇怪,WebClient也显示了类似的问题:

        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));
收益率:

  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)
System.Net.WebException未处理
Message=WebClient请求期间发生异常。
堆栈跟踪:
位于System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfEssential()处
在System.Net.DownloadStringCompletedEventArgs.get_Result()中
在OddballHttp.MainPage.b__0(对象o,DownloadStringCompletedEventArgs args)
在System.Net.WebClient.OnDownloadStringCompleted(下载StringCompletedEventArgs e)中
在System.Net.WebClient.DownloadStringOperationCompleted(对象参数)处
在System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi、对象obj、BindingFlags invokeAttr、绑定器绑定器、对象参数、CultureInfo区域性、布尔值isBinderDefault、程序集调用者、布尔值验证访问、堆栈爬网标记和堆栈标记)
位于System.Reflection.RuntimeMethodInfo.InternalInvoke(对象obj、BindingFlags invokeAttr、绑定绑定器、对象[]参数、CultureInfo区域性、StackScrawMark和stackMark)
在System.Reflection.MethodBase.Invoke(对象obj,对象[]参数)处
位于System.Delegate.DynamicInvokeOne(对象[]args)
位于System.MulticastDelegate.DynamicInvokeImpl(对象[]args)
位于System.Delegate.DynamicInvoke(对象[]args)
在System.Windows.Threading.DispatcherOperation.Invoke()中
在System.Windows.Threading.Dispatcher.Dispatch中(DispatcherPriority优先级)
位于System.Windows.Threading.Dispatcher.OnInvoke(对象上下文)
位于System.Windows.Hosting.CallbackCookie.Invoke(对象[]args)
位于System.Windows.Hosting.DelegateWrapper.InternalInvoke(对象[]args)
位于System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle、Int32 nParamCount、ScriptParam[]pParams、ScriptParam&pResult)
InnerException:System.ArgumentException
Message=“”
堆栈跟踪:
位于System.Net.Browser.AsyncHelper.BeginNoui(SendOrPostCallback beginMethod,对象状态)
位于System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
在System.Net.WebClient.GetWebResponse(WebRequest请求,IAsyncResult结果)
在System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult结果)
在System.Net.Browser.ClientHttpWebRequest.c__中显示ClassA.b__8(对象状态2)
位于System.Threading.ThreadPool.WorkItem.WaitCallback\u上下文(对象状态)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态)
在System.Threading.ThreadPool.WorkItem.doWork(对象o)处
在System.Threading.Timer.ring()中
InnerException:System.ArgumentException
消息=参数不正确。
堆栈跟踪:
在MS.Internal.XcpImports.CheckHResult(UInt32小时)
在MS.Internal.XcpImports.WebRequest\u发送(InternalWebRequest请求)
在MS.Internal.InternalWebRequest.Send()处
在System.Net.Browser.ClientHttpWebRequest.PrepareAndSendRequest(字符串方法、Uri请求Uri、流请求BodyStream、WebHeaderCollection headerCollection、CookieContainer CookieContainer)
在System.Net.Browser.ClientHttpWebRequest.BeginGetResponseImplementation()中
在System.Net.Browser.ClientHttpWebRequest.InternalBeginGetResponse(异步回调,对象状态)
位于System.Net.Browser.ClientHttpWebRequest.BeginGetResponse(异步回调,对象状态)
在System.Net.WebClient.DownloadBits(WebRequest请求、流写入流、CompletionDelegate CompletionDelegate、AsyncOperation asyncOp)
位于System.Net.WebClient.DownloadStringAsync(Uri地址,对象userToken)
位于System.Net.WebClient.DownloadStringAsync(Uri地址)
在OddballHttp.MainPage.MainPage_加载(对象发送方,RoutedEventArgs e)
位于MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32类型索引、委托handlerDelegate、对象发送器、对象参数)
在MS.Internal.JoltHelper.firevent处(IntPtr unmanagedObj、IntPtr unmanagedobjars、Int32 argsTypeIndex、Int32 actualgstypeindex、String eventName)

试过了,确实有些奇怪。除了fanbóys.org/domain中的url外,代码使用任何提供的url都像一个符咒。
  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)