如何重定向到另一个服务器在mvc使用post方法
How to redirect to another server in mvc using post method?
我想从控制器重定向到另一个域服务器。
我还必须从服务器得到一个响应。
如何在ASP中实现这一点。净MVC吗?
我们还没有实现Model部分。我找到了一个解决web表单的方法。
You can use the HttpWebRequest class to make the post to the other server and then redirect as normal
//code would be something like this
var httpRequest = (HttpWebRequest)WebRequest.Create("http:your url");
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
string data = "key=value&key2=value2";
byte[] dataArray = Encoding.UTF8.GetBytes(data);
httpRequest.ContentLength = dataArray.Length;
//actual code to call another server
using(Stream requestStream = httpRequest.GetRequestStream())
{
requestStream.Write(dataArray, 0, dataArray.Length);
var webResponse = (HttpWebResponse)httpRequest.GetResponse();
}
相关文章:
- MVC:使用Web窗体视图引擎在javascript中迭代Viewbag数组
- MVC 4:使用 JQUERY 和 PartViewResult 动态创建 HTML 文本框.如果代码是动态添加的,如何
- MVC 4使用Razor禁用多个下拉列表中的值
- C# asp.net MVC - 使用参数从 html.actionlink 调用脚本函数
- Spring MVC使用JavaScript以这种格式调用和返回数据
- MVC使用jquery而不是提交按钮
- MVC:使用javascript设置操作名称失败
- Javascript MVC+使用jQuery侦听和调度事件
- MVC:使用JQuery在模式中切换复选框可见性
- 多个文件上传使用MVC使用jquery文件上传插件
- MVC使用javascript将日期范围传递给控制器
- MVC 3使用下拉列表和ajax来获取新模型
- Mvc:使用javascript数组从json中获取值到Mvc控制器
- 在特定的单选按钮点击启用文本框/下拉列表在MVC使用jquery
- ASP.NET MVC -使用javascript在运行时添加表单元素
- asp.net mvc-使用Javascript或jQuery迭代Gridview以找到最大的价值
- MVC-使用POST参数打开网页
- Asp.net MVC使用Ajax从PartialView的actionlink加载父视图不起作用
- asp.net mvc-使用Javascript获取mvc表单数据
- MVC使用Ajax上传和保存表单图像