开发者

ASP.Net delay, how can I tell if it is the client or the server?

开发者 https://www.devze.com 2023-03-07 06:19 出处:网络
I\'ve got a generic handler on a site.When I go directly to it it responds immediately.When I try to get to it from a .Net program, there is a long (10 second give or take) pause before the server is

I've got a generic handler on a site. When I go directly to it it responds immediately. When I try to get to it from a .Net program, there is a long (10 second give or take) pause before the server is registering the request.

Here is the code I'm using to hit the server:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://MYURL/fs.ashx");
request.Method = "POST";
request.ContentType = "text/xml";

// This is the line that takes 10 seconds to return
StreamWriter streamOut = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);

streamOut.Write(sXMLToSend);
streamOut.Close();
XmlDocument doc = new XmlDocument();
HttpWebResponse resp = null;
resp = (HttpWebResponse)request.GetResponse();
StreamReader responseReader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
sResponse = responseReader.ReadToEnd();
Console.WriteLine(开发者_如何学GosResponse);
resp.Close();

I don't think that this line was taking that long about a week ago, but I don't have any data to back that up. Any ideas what the issue could be? If I hit the url in a browser it responds immediately. Are there any tools that I can use to figure out if it is my machine, or the server, or...I don't even know where to begin.


Might it just be due to the fact that GetRequestStream is a synchronous method and its buffering it all up before returning? Maybe you should try calling the async version and process data as it comes in.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号