从C# Windows应用程序调用URL

3
我有一个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);

感谢您的选择。

1
可能是重复的问题:C# - 如何进行 HTTP 调用 - dandan78
可能是[调用URL - c#]的重复问题(https://dev59.com/SXE85IYBdhLWcg3wgDvd)。 - Joe Taylor
2个回答

5

你尝试过使用 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(); 

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接