从 C# Windows 应用程序调用 url

Call a url from C# Windows Application

我有一个 url 可以向提供的手机号码发送短信。我只想从 windows 应用程序调用此 url 但不想在浏览器中打开。我只想从我的 windows 应用程序中执行那个 url。

url

的例子
    http://mycompany.com/sms.aspx?mobilenum=9123444777&Message=this is a test message

我试过这种方法。但是它是在浏览器中打开的。 我不想在浏览器中打开它。我只想在内部执行这一行。

    System.Diagnostics.ProcessStartInfo sInfo = new     
    System.Diagnostics.ProcessStartInfo("http://mycompany.com
    /sms.aspx?mobilenum=9123444777&Message=this is a test message");
    System.Diagnostics.Process.Start(sInfo);

谢谢。

你不能 "execute" url 那样... URL 是一个资源地址,你只能通过向远程服务器发送请求来使用它。因此,您希望使用查询字符串 post 数据(发出 HTTP 请求)。例如,您可以通过使用 WebClient class...

来实现

http://msdn.microsoft.com/en-us/library/system.net.webclient%28v=vs.110%29.aspx

您尝试过使用 HttpWebRequest 吗?

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://mycompany.com/sms.aspx?mobilenum=9123444777&Message=this%20is%20a%20test%20message");
WebResponse response = request.GetResponse();
response.Close();