我打電話給我的方法就像HttpWebRequest,它會給我這樣的錯誤 我的代碼是這樣的。錯誤WP7 HttpWebRequest調用方法
HttpWebRequest objHttpWebRequest = System.Net.WebRequest.CreateHttp("http://url");
objHttpWebRequest.BeginGetResponse(r =>
{
WebResponse response = null;
try
{
response = objHttpWebRequest.EndGetResponse(r); //End Async Call to the URL
using (var stream = response.GetResponseStream())
using (var reader = new StreamReader(stream)) //get data in StreamReader
{
string contents = reader.ReadToEnd(); //read content from reader and store it in content
XElement xmlResult = XElement.Parse(contents);
AEGAPI.clsGlobal.RandomToken = xmlResult.Value;
}
我的錯誤報告是
System.NotSupportedException occurred
Message=Timeouts are not supported on this stream.
StackTrace:
at System.IO.Stream.get_WriteTimeout()
at MS.Internal.InternalNetworkStream.get_Length()
at System.IO.StreamReader.ReadToEnd()
at AEGAPI.clsAEGAPI.<>c__DisplayClass3.<Authenticate>b__0(IAsyncResult r)
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()
感謝您的幫助!
你有什麼樣的錯誤? –
此流不支持超時。 –
哦,我明白了。我第一次遇到了麻煩。 –