我正在尝试验证一个HttpWebRequest
. 我的代码是这样的
string url = "http://mydomain.com";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpCookie cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
req.Headers[HttpRequestHeader.Cookie] = string.Format("{0}={1}", cookie.Name, cookie.Value);
WebResponse res = req.GetResponse();
一切正常,直到最后一行执行(WebResponse res = req.GetResponse();)。当最后一行执行时,代码执行回到第一行(string url = "string url = "http://mydomain.com";"; ) 并重新开始,这种情况发生了很多次,以至于发生了超时异常。