Home > php教程 > php手册 > body text

.net后台如何跨域向PHP服务器post 数据(json)

WBOY
Release: 2016-06-06 19:40:32
Original
1398 people have browsed it

@@大灰狼: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; // 接着设置其它的http标头,可以通过抓包拿到 contenttype等标头信息。 YourClass obj =new YourClass(); // 将你的YourClass序列化为json格式 Json

@@大灰狼: 

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

request.Method = "POST";

// 接着设置其它的http标头,可以通过抓包拿到 contenttype等标头信息。

YourClass obj =new YourClass();

// 将你的YourClass序列化为json格式

JsonSerializer formater =new JsonSerializer ();

formater.Serialize(ms,obj);

//然后通过 request.GetRequestStream() 拿到 Stream ,再把上面序列化出来的内容通过 Stream.Write写入请求中。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template