How to call an external URL from an ASP.NET MVC solution

The first message ever. So better do it good.

I have an ASP.NET MVC 2 web application in which I have actionResult, I need to call me.

What I need is AR to handle some data operations, and after that I need it to call an external URL, which is actually a corporate module that processes sending messages to our company phones.

You just need to call the url that looks like this:

string url = "http://x.x.x.x/cgi-bin/npcgi?no=" + phoneNumber + "&msg=" + message;

I do not need any return message or anything else. I just want to name this external URL, which, of course, goes beyond the scope of my own web application. (I do not want to redirect). This URL should be invoked behind the graphical interface without the possibility ever realized by the user. And the page they are viewing should not be affected.

I tried:

Server.Execute(url);

However, it did not work out. I heard some ppl go about this having a hidden iFrame on the page. Installing src on the url may be necessary, and then somehow do this to get the call. For me, this does not seem so elegant, but if this is the only solution, someone has an example of how this is done. Or, if you have a smoother sentence, I'm all ears.

+5
3

- :

 string messageToCallInPatient = "The doctor is ready to see you in 5 minutes. Please wait outside room " + roomName;
 string url = "http://x.x.x.x/cgi-bin/npcgi?no=" + phoneNumber + "&msg=" +
               messageToCallInPatient;
 HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(string.Format(url));
 webReq.Method = "GET";
 HttpWebResponse webResponse = (HttpWebResponse)webReq.GetResponse();

 //I don't use the response for anything right now. But I might log the response answer later on.   
 Stream answer = webResponse.GetResponseStream();
 StreamReader _recivedAnswer = new StreamReader(answer);
+6

url, -

   WebClient wc = new WebClient();
   wc.UploadProgressChanged += (sender, evtarg) =>
            {
                Console.WriteLine(evtarg.ProgressPercentage);
            };

        wc.UploadDataCompleted += (sender, evtarg) =>
            {
                String nResult;
                if (evtarg.Result != null)
                {
                    nResult = Encoding.ASCII.GetString(evtarg.Result);
                    Console.WriteLine("STATUS : " + nResult);
                }
                else
                    Console.WriteLine("Unexpected Error");

            };


        String sp= "npcgi??no=" + phoneNumber + "&msg=" + message;
        System.Uri uri = new Uri("http://x.x.x.x/cgi-bin/");
        wc.UploadDataAsync(uri, System.Text.Encoding.ASCII.GetBytes(sb);

HTTP POST ( URL- )

+1

"return Redirect (url)";

0

All Articles