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

I have a strange problem accessing the following URL:

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


Here is the code:

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


Reading the response using request.EndGetResponse () throws this exception:

 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' 


As far as i can tell url

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

has a good shape.
All the browsers I tried can handle this.

Testing with Fiddler shows that an HTTP request is not sent from the Windows Phone emulator.

If you tried several different URLs (with an active Fiddler instance):

 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. 

The problem can be reproduced with the emulator and on the device.
I assume this might be related to DNS.
I do not control the link website and its DNS record.

Any ideas?

+7
source share
1 answer

Yup, I can also check the problem, and also not see the traffic in the violin. The strangest mistake!

  string url = "http://a--bc.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 

Interestingly, the exception has already occurred before "EndGetResponse" - if you look in the "_exception" private field before "EndGetResponse" is called.

Not surprisingly, WebClient also shows a similar problem:

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

Productivity:

  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) 
0
source

All Articles