如何调用从ASP.NET MVC解决方案,外部URL [英] How to call an external URL from a ASP.NET MVC solution

查看:141
本文介绍了如何调用从ASP.NET MVC解决方案,外部URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一篇文章所固有如初。所以最好让一个很好的。

First post inhere ever. So better make it a good one.

我有,我有一个ActionResult一个ASP.NET MVC 2的Web应用程序,我需要为我做的电话。

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

问题是我需要这个A.R处理一些数据的操作之后,我需要它来调用它实际上是一个公司模块处理发送消息到我们公司的手机电话的外部URL。

The thing is I need this A.R to handle some data operations and after that I need it to call an external URL which is actually a Company Module that handles sending messages to our company handset phones.

它只是需要调用看起来像这样的网址:

It just needs to call the URL that looks like this:

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

我不需要任何回报的消息或任何东西。只是想叫这当然是我自己的Web应用程序的范围之外的外部URL。 (我不想重定向)。该URL必须在GUI后面叫无需用户不断实现。而且,他们正在查看的页面必须不会受到影响。

I don't need any return message or anything. Just want to call that external URL which is of course outside the scope of my own web application. (I do not want to Redirect). That URL must be called behind the GUI without the user ever realising. And the page that they are viewing must not be affected.

我试着用:

Server.Execute(url);

但没有奏效。我听说一些脂肪酶去这所具有页面上隐藏iFrame。在将src设置为URL人们可能需要,然后以某种方式执行的,得到实例化的呼叫。它似乎不那么优雅的我,但如果这是唯一的解决方案,没有任何人有一个例子为如何做到这一点。或者,如果你有一个更圆滑的建议,我洗耳恭听。

However did not work. I've heard that some ppl go about this by having a hidden iFrame on the page. The setting the src to the url one may need and then somehow execute that, to get the call instantiated. It doesn't seem so elegant to me, but if that is the only solution, does anyone have an example as to how that is done. Or if you have a more sleek suggestion I am all ears.

在此先感谢

汤姆。

推荐答案

我终于得到它这片code的工作:

I finally got it working with this piece of code:

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

这篇关于如何调用从ASP.NET MVC解决方案,外部URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆