尝试了一天,尝试了各种方法,一下方法最直接方便.

//地址
string _url = "https://www.dXXXayup.ink/api/User/Login";
//json参数
string jsonParam = "{ phonenumber:\"18665885202\",pwd:\"tsp\"}";
var request = (HttpWebRequest)WebRequest.Create(_url);
request.Method = "POST";
request.ContentType = "application/json;charset=UTF-8";
byte[] byteData = Encoding.UTF8.GetBytes(jsonParam);
int length = byteData.Length;
request.ContentLength = length;
Stream writer = request.GetRequestStream();
writer.Write(byteData, , length);
writer.Close();
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")).ReadToEnd();
MessageBox.Show(responseString.ToString());
       

C#使用post方式提交json数据的更多相关文章

  1. 前端ajax用post方式提交json数据给后端时,网络报错 415

    项目框架:spring+springmvc+mybatis 问题描述:前端ajax用post方式提交json数据给后端时,网络报错 415 前端异常信息:Failed to load resource ...

  2. 导出excel时,以form方式提交json数据

    今天在写项目时写到一个excel的导出,开始想用ajax请求后台后导出,但发现ajax会有返回值,而且ajax无法直接输出文件,而后台的excel导出方法已经封装好,不方便修改. 就改用了提交的方式f ...

  3. window.location.href方式提交json数据

    ${ctx}/vehicleFlow/to_vehflow_detail.do?strJson="+encodeURIComponent(json)

  4. ngResource提交json数据如何带参数

    ngResource提交json数据如何带参数 直接使用ngResource和REST服务接口交互可以让程序显得简洁,前提是配置好跨域和OPTIONS请求的支持,与此同时,如果需要带些额外的参数,有两 ...

  5. J2EE Web开发入门—通过action是以传统方式返回JSON数据

    关键字:maven.m2eclipse.JSON.Struts2.Log4j2.tomcat.jdk7.Config Browser Plugin Created by Bob 20131031 l ...

  6. django 使用Ajax方式POST JSON数据包

    示例1: js: function SaveAction(){ //点击 保存按键 var senddata = {"type":"A", "host ...

  7. Jquery Ajax 提交json数据

    在MVC控制器(这里是TestController)下有一个CreateOrder的Action方法 [HttpPost] public ActionResult CreateOrder(List&l ...

  8. Jquery-ajax()方法提交json数据

    1.ajax()提交json数据代码 var strJson = getStrPayJson(); $.ajax({ type: "POST", url: "/userc ...

  9. ajax提交json数据到后端C#解析

    本文链接:https://blog.csdn.net/qq_22103321/article/details/78015920 前端提交json数据 $.ajax({ type: "post ...

随机推荐

  1. 服务器CPU很高,频繁FullGC排查小总结

    可以分为如下步骤: ①通过 top 命令查看 CPU 情况,如果 CPU 比较高,则通过 top -Hp 命令查看当前进程的各个线程运行情况. 找出 CPU 过高的线程之后,将其线程 id 转换为十六 ...

  2. 关于SQLite数据库 字段 DateTime 类型

    这两天刚接触SQLite 数据库 还没有太过于深入的了解 , 于是出现了一个问题 : 我在 C#中 ,使用SQLiteHelper 查询SQLite数据库数据时,报了这个错误: System.Form ...

  3. cppcheck代码检测

    cppcheck -hCppcheck - A tool for static C/C++ code analysis Syntax: cppcheck [OPTIONS] [files or pat ...

  4. 笔记7:Jquery知识

    jQuery 1 基本知识 jQuery 是一个 JavaScript 库.jQuery 极大地简化了 JavaScript 编程.其下载地址:http://jquery.com/download/ ...

  5. 15-numpy笔记-莫烦pandas-3

    代码 import pandas as pd import numpy as np dates = pd.date_range('20130101', periods=6) df=pd.DataFra ...

  6. GitHub操作(五)

    GitHub 是一个面向开源及私有软件项目的托管平台,因为只支持 Git 作为唯一的版本库格式进行托管,故名 GitHub. 1. 打开浏览器,输入GitHub的网址https://github.co ...

  7. [LeetCode] 7. Reverse Integer 翻转整数

    Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Examp ...

  8. Codechef Chef Cuts Tree

    该思博的时候就思博到底,套路的时候不能再套路的一道题 首先我们将联通块的大小平方和进行转化,发现它就等价于连通点对数,而这个可以转化为连接两点的边数(距离)和 所以我们考虑第\(i\)天时,一个点对\ ...

  9. Web数据交互技术

    作者 | Jeskson 来源 | 达达前端小酒馆 web的概念 web叫全球广域网,可以叫做万维网,是一种分布式结构,建立在Internet上的网络服务.万维网共享分布在网络上的各个服务器中的所有互 ...

  10. .NET Core:跨域

    在Startup中的ConfigureServices方法中配置:services.AddCors(options => options.AddPolicy("any", b ...