我对此有点打击,我有多个线程提出网页请求的片段代码
var request = (HttpWebRequest)WebRequest.Create(uri) as HttpWebRequest;
request.Accept = "application/xml";
request.Method = shopfiyRequest.ActionType.ToString();
if (string.IsNullOrEmpty(shopfiyRequest.ContentType))
request.ContentType = shopfiyRequest.ContentType;
// authentication
var cache = new CredentialCache();
cache.Add(uri, "Basic", new NetworkCredential(apiKey, password));
request.Credentials = cache;
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
HttpWebResponse response = null;
Log.Debug("Getting responsce from shopify");
// This is where the HTTP GET actually occurs.
response = (HttpWebResponse)request.GetResponse();
一旦线程点击行response = (HttpWebResponse)request.GetResponse();
,它就会抛出异常
无法评估表达式,因为代码已优化或本机框架位于调用堆栈之上。
I have tried catching and ignoring abort exception,但似乎无济于事
任何帮助或内部的帮助都是值得的。