gpt4 book ai didi

windows-phone-7 - HttpWebRequest 无法访问 http ://xn--fanbys-exa. org/episodes.m4a.rss

转载 作者:行者123 更新时间:2023-12-04 12:59:27 25 4
gpt4 key购买 nike

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

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



这是代码:
    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'

据我所知网址

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



格式良好。
我试过的所有浏览器都可以处理它。

使用 Fiddler 进行的测试表明,没有从 Windows Phone 模拟器发送 HTTP 请求。

如果尝试了几个不同的 URL(使用事件的 Fiddler 实例):
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.

可以使用模拟器和设备重现该问题。
我的猜测是这可能与 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”之前查看私有(private)字段“_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)

关于windows-phone-7 - HttpWebRequest 无法访问 http ://xn--fanbys-exa. org/episodes.m4a.rss,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10868583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com