3

I have a url which sends sms to the provided mobile numbers. I want to just call this url from windows application but not to open in browser. I just want to execute that url from my windows application.

example of url

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

I have tried in this way. But it is opening in a browser. I dont want this to be opened in a browser. I just want to execute this line internally.

    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);

Thanks.

Shahid Aleem
  • 73
  • 1
  • 1
  • 8
  • 1
    possible duplicate of [C# - How to make a HTTP call](http://stackoverflow.com/questions/7688350/c-sharp-how-to-make-a-http-call) – dandan78 Jan 06 '15 at 11:18
  • possible duplicate of [Invoking a URL - c#](http://stackoverflow.com/questions/2744840/invoking-a-url-c-sharp) – Joe Taylor Jan 06 '15 at 11:28

2 Answers2

5

Have you tried to use a 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(); 
kjbartel
  • 10,381
  • 7
  • 45
  • 66
1

You can't "execute" url like that... URL is an address of a resource that you can use only by sending a request to the remote server. So instead you want to post data using a query string (make an HTTP request). You can achieve that for example by using WebClient class...

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

walther
  • 13,466
  • 5
  • 41
  • 67