首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MVC 3应用程序能否在同一服务器上的不同应用程序中执行操作

MVC 3应用程序能否在同一服务器上的不同应用程序中执行操作
EN

Stack Overflow用户
提问于 2014-01-17 03:56:05
回答 1查看 64关注 0票数 0

我有两个asp.net应用程序运行在一个服务器上,一个是MVC-3,另一个不是.MVC应用程序有一个POST操作,它发送电子邮件并返回一个JSON对象。普通的asp.net应用程序能够以某种方式执行操作(从服务器)并接收JSON对象吗?我想它只是需要以某种方式执行一个帖子?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-21 01:27:26

找到答案:它是HttpWebRequest方法,如下所示。

代码语言:javascript
复制
string data = "data to post";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("put URL here"); 
// set post headers
request.Method = "POST";
request.KeepAlive = true;
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
System.IO.StreamWriter writer = new System.IO.StreamWriter(request.GetRequestStream());
writer.Write(data);
writer.Close();
writer.Dispose();
// next line posts the data to the URL
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21177558

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档