I have a strange issue accessing the following url:
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 with 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 the url
is wellformed.
All browsers that I tried can handle it.
Testing with Fiddler shows that no HTTP request is being sent from the Windows Phone emulator.
If have 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 issue can be reproduced with the emulator and on the device.
My guess is that this might be DNS related.
I have no control over the referenced web site and its DNS entry.
Any ideas ?