简体   繁体   English

使用VB.NET发送HTTP命令

[英]Send HTTP Command using VB.NET

I'm trying to send an HTTP command using VB.NET and I'm not quite sure how to do it. 我正在尝试使用VB.NET发送HTTP命令,我不太清楚如何做到这一点。 I don't want to actually navigate to the page, just execute the command. 我不想实际导航到页面,只需执行命令。

http://xbmc.local/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary%28video%29

What I'm doing is building an integrated interface for my XBMC home theater, and my home automation. 我正在做的是为我的XBMC家庭影院和我的家庭自动化构建一个集成界面。

You can use the WebRequest object to send an HTTP Request. 您可以使用WebRequest对象发送HTTP请求。

' Create a WebRequest object with the specified url. ' 
Dim myWebRequest As WebRequest = WebRequest.Create(url)

' Send the WebRequest and wait for response. ' 
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

The WebResponse class has a number of properties you can check to see if the request succeeded or not. WebResponse类有许多属性,您可以检查它们是否成功。 And just something to be aware of, GetResponse() will throw an exception if it times out. 而且要注意的是, GetResponse()会在超时时抛出异常。

Try the following 请尝试以下方法

Dim client = WebRequest.Create("http://xbmc.local/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary%28video%29")
Dim response = client.GetResponse()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM