WebRequest.GetResponse()在第一次尝试时挂起.不向网络发送任何数据 [英] WebRequest.GetResponse() Hangs on first try. does not send data any to network

查看:55
本文介绍了WebRequest.GetResponse()在第一次尝试时挂起.不向网络发送任何数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试我认为是简单的操作.    我无法通过webrequest发送任何请求 取得回应.  我可以通过浏览器快速响应.  然后我用了wireshark,它表明有 甚至没有请求.

I am trying what I thought was a simple operation.    I am not able to send any request with webrequest    get response.   I am able to get a quick response with a browser.   I then used wireshark and it shows that there is not even a request going out.

这是代码

 程序在请求中挂起.GetResponse                                 

  program hangs in request.GetResponse                                  

库是否已损坏?

我已经花了数小时的时间-所有帮助将不胜感激.

I have spent hours  with this - all help will be appreciated.

  var request = (HttpWebRequest)WebRequest.Create(@"http://10.184.44.97:8085/logs/");
            request.Accept = "text/html";
            request.Method = "GET";
            request.ContentType = "text/html";
        
            Stopwatch sw = new Stopwatch();
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            sw.Stop();
                Console.WriteLine("{0} response time = {1}");



霍华德·戴维斯

推荐答案

你好霍华德,

有趣的一个;没有上面的第一手经验,因为您上面的代码看起来不错.  我假设没有引发异常,并且您看到了控制台写指令行吗?

Interesting one; no first hand experience of this one as the code you have above looks fine.  I am assuming no exceptions are thrown and that you see the console writeline?

那么我的猜测是与端口相关的东西可以阻止这种情况的发生.您是否尝试过80端口?  如果可以,那么我将集中精力确保8085已打开.  我的猜测是有一些低水平的东西正在阻止它(防火墙).

My guess then would be something port related blocking this from happening.  Have you tried port 80?  If so and it works then I would concentrate on making sure 8085 is open.  My guess is something low level is blocking this (firewall).

请发布您发现的内容!

Please post what you find! 


这篇关于WebRequest.GetResponse()在第一次尝试时挂起.不向网络发送任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆