zoukankan      html  css  js  c++  java
  • C# 后台访问接口

    string idcard = this.labIdcard.Text.ToString();
    string url = ConfigurationManager.AppSettings["apiIp"].ToString();
    string action = "/api/action?" + idcard;
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url + action);
    webRequest.ContentType = "text/json;charset="utf-8"";
    webRequest.Accept = "text/json";
    webRequest.Method = "get";
    var httpResponse = (HttpWebResponse)webRequest.GetResponse();
    var streamReader = new StreamReader(httpResponse.GetResponseStream());
    var result = streamReader.ReadToEnd();
    JObject jo = (JObject)JsonConvert.DeserializeObject(result);
    string code = jo["code"].ToString();
    if (code == "200") {
    BindList();
    }
    
     
    
     
    
    
    string idcard = this.labIdcard.Text.ToString();
    string url = ConfigurationManager.AppSettings["apiIp"].ToString();
    string action = "/api/action?" + idcard;
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url + action);
    webRequest.ContentType = "text/json;charset="utf-8"";
    webRequest.Accept = "text/json";
    webRequest.Method = "post";
    string json = new JavaScriptSerializer().Serialize(new {
    secret = secret,
    szdw = szdw
    });
    //传参
    byte[] buffer = Encoding.GetEncoding("UTF-8").GetBytes(json);
    Stream requestStream = webRequest.GetRequestStream();
    requestStream.Write(buffer, 0, buffer.Length);
    requestStream.Close();
    var httpResponse = (HttpWebResponse)webRequest.GetResponse();
    var streamReader = new StreamReader(httpResponse.GetResponseStream());
    var result = streamReader.ReadToEnd();
    JObject jo = (JObject)JsonConvert.DeserializeObject(result);
    string code = jo["code"].ToString();
    if (code == "200") {
    BindList();
    }
  • 相关阅读:
    初步学习next.js-1-新建项目
    对象比较-深层,浅层
    制作右键菜单
    使用高德API-初级应用
    启动前后端连载方法
    使用websocket
    关于图片压缩
    归并排序(mergesort)
    冒泡排序
    递归介绍
  • 原文地址:https://www.cnblogs.com/sdya233/p/14704803.html
Copyright © 2011-2022 走看看