C# - How to make a HTTP call

前端 未结 3 828
花落未央
花落未央 2020-11-29 08:28

I wanted to make an HTTP call to a website. I just need to hit the URL and dont want to upload or download any data. What is the easiest and fastest way to do it.

I

3条回答
  •  甜味超标
    2020-11-29 08:41

    You've got some extra stuff in there if you're really just trying to call a website. All you should need is:

    WebRequest webRequest = WebRequest.Create("http://ussbazesspre004:9002/DREADD?" + fileName);
    WebResponse webResp = webRequest.GetResponse();
    

    If you don't want to wait for a response, you may look at BeginGetResponse to make it asynchronous .

提交回复
热议问题