1:aspx内容

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Push.aspx.cs" Inherits="_jichu_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
#submit_Push
{
}
</style>
</head>
<body>
<form id="form_Push" runat="server">
<div style="margin: 0 auto; width: 800px">
<table>
<tr>
<td>车款ID:</td>
<td>
<input type="text" id="text_CarModelID" runat="server" readonly="true" />
</td>
</tr>
<tr>
<td>VIN码:</td>
<td>
<input type="text" id="text_Vin" runat="server" readonly="true" />
</td>
</tr>
<tr>
<td>发动机号:</td>
<td>
<input type="text" id="text_EngineNumber" runat="server" readonly="true" />
</td>
</tr>
<tr>
<td>车牌号:</td>
<td>
<input type="text" id="text_CarBrandNumber" runat="server" />
</td>
</tr>
<tr>
<td>车辆归属地:</td>
<td>
<select id="select_CarProvince" runat="server">
<option>北京市</option>
<option>河南省</option>
</select>
<select id="select_CarCity" runat="server">
<option>北京市</option>
<option>郑州市</option> </select>
<select id="select_CarDistrict" runat="server">
<option>海淀区</option>
<option>中原区</option>
</select>
</td>
</tr>
<tr>
<td>车辆购置价:</td>
<td>
<input type="text" id="text_PurchasePrice" runat="server" />
</td>
</tr>
<tr>
<td>初登日期:</td>
<td>
<input type="text" id="text_RegisterDate" runat="server" readonly="true" value="2012-6-1" />
</td>
</tr>
<tr>
<td>发票日期:</td>
<td>
<input type="text" id="text_InvoiceDate" runat="server" value="2012-8-1" />
</td>
</tr>
<tr>
<td>客户姓名:</td>
<td>
<input type="text" id="text_ClientName" runat="server" readonly="true" />
</td>
</tr>
<tr>
<td>客户手机:</td>
<td>
<input type="text" id="text_ClientPhone" runat="server" readonly="true" />
</td>
</tr>
<tr>
<td>证件类型:</td>
<td>
<input type="text" id="text_PapersType" runat="server" readonly="true" />
</td>
</tr>
<tr>
<td>证件号码:</td>
<td>
<input type="text" id="text_PapersNumber" runat="server" readonly="true" />
</td>
</tr>
<tr>
<td>客户所在地:</td>
<td>
<select id="select_ClientProvince" runat="server">
<option>北京市</option>
<option>河南省</option>
</select>
<select id="select_ClientCity" runat="server">
<option>北京市</option>
<option>郑州市</option>
</select>
<select id="select_ClientDistrict" runat="server">
<option>海淀区</option>
<option>中原区</option>
</select>
详细地址:<input type="text" runat="server" id="text_ClientAddress" />
</td>
</tr>
<tr>
<td>客户邮编:</td>
<td>
<input type="text" id="text_ClientPost" runat="server" />
</td>
</tr>
<tr>
<td>客户邮箱:</td>
<td>
<input type="text" id="text_ClientEmail" runat="server" />
</td>
</tr>
<tr>
<td>新旧程度:</td>
<td>
<select id="select_CarDegree" runat="server">
<option>二手车</option>
<option>新车</option>
</select>
</td>
</tr>
<tr>
<td>签约时间:</td>
<td>
<input type="text" id="text_SingDate" runat="server" />
</td>
</tr>
<tr>
<td>生效时间:</td>
<td>
<input type="text" id="text_TakeEffectDate" runat="server" />
</td>
</tr>
<tr>
<td>起始公里数:</td>
<td>
<input type="text" id="text_StartKM" runat="server" />
</td>
</tr>
<tr>
<td>产品名称:</td>
<td>
<select id="select_ProdutName" runat="server">
<option>专享A套餐</option>
<option>268V-B套餐</option>
</select>
</td>
</tr>
<%-- <tr>
<td>产品类别:</td>
<td>
<select id="select_ProdutType" runat="server">
<option>动力智选-Day1</option>
</select>
</td>
</tr>--%>
<tr>
<td>销售公司:</td>
<td>
<input type="text" id="text_SaleCompany" runat="server" />
</td>
</tr>
<tr>
<td>附件:</td>
<td>
<span id="span_Enclosure" runat="server">附件1|附件2</span>
</td>
</tr>
<tr>
<td>合同备注:</td>
<td>
<textarea id="text_ContractRemarks" runat="server"></textarea>
</td>
</tr>
<tr>
<td>
<asp:Button ID="submit_Push" runat="server" OnClick="BtnSubmit" Text="推送" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

2:aspx.cs内容


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json; public partial class _jichu_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetValue();
}
} private void GetValue()
{
text_CarModelID.Value = "";
text_Vin.Value = "D1111111111111121";
text_EngineNumber.Value = "D1111111111111111";
text_CarBrandNumber.Value = "京D11111";
text_PurchasePrice.Value = "";
text_RegisterDate.Value = "2016-6-1";
text_InvoiceDate.Value = "2016-6-1";
text_ClientName.Value = "客户姓名";
text_ClientPhone.Value = "";
text_PapersType.Value = "身份证";
text_PapersNumber.Value = "";
text_ClientAddress.Value = "客户地址";
text_ClientPost.Value = "客户邮编";
text_ClientEmail.Value = "客户邮箱";
text_SingDate.Value = "2016-6-1";
text_TakeEffectDate.Value = "2016-6-1";
text_StartKM.Value = "";
span_Enclosure.InnerText = "https://www.baidu.com/img/bd_logo.png|https://www.baidu.com/img/bd_logo1.png";
text_SaleCompany.Value = "销售公司";
text_ContractRemarks.Value = "合同备注";
} #region 点击推送
public void BtnSubmit(object sender, EventArgs e)
{
JsonModel model_Json = new JsonModel();
model_Json.A = text_CarModelID.Value;
model_Json.B = text_Vin.Value;
model_Json.C = text_EngineNumber.Value;
model_Json.D = text_CarBrandNumber.Value;
model_Json.E1 = select_CarProvince.Value;
model_Json.E2 = select_CarCity.Value;
model_Json.E3 = select_CarDistrict.Value;
model_Json.F = text_PurchasePrice.Value;
model_Json.G = text_RegisterDate.Value;
model_Json.H = text_InvoiceDate.Value;
model_Json.I = text_ClientName.Value;
model_Json.J = text_ClientPhone.Value;
model_Json.K = text_PapersType.Value;
model_Json.L = text_PapersNumber.Value;
model_Json.M1 = select_ClientProvince.Value;
model_Json.M2 = select_ClientCity.Value;
model_Json.M3 = select_ClientDistrict.Value;
model_Json.M4 = text_ClientAddress.Value;
model_Json.N = text_ClientPost.Value;
model_Json.N1 = text_ClientEmail.Value;
model_Json.O = select_CarDegree.Value;
model_Json.P = text_SingDate.Value;
model_Json.Q = text_TakeEffectDate.Value;
model_Json.R = text_StartKM.Value;
model_Json.S = select_ProdutName.Value;
model_Json.T = span_Enclosure.InnerText; //附件需绝对路径
model_Json.U = text_SaleCompany.Value;
model_Json.X = text_ContractRemarks.Value;
model_Json.Y = "hina";
model_Json.Z = "8A2399F8DC0C8F15CEB4";
string result = PostData("http://localhost:6385/Web/GetPush_Zs.ashx", JsonConvert.SerializeObject(model_Json), Encoding.UTF8);
ResultMSG model_ResultMSG = JsonConvert.DeserializeObject<ResultMSG>(result);
//执行操作数据库
}
#endregion #region Post访问外部地址
/// <summary>
/// Post访问外部地址
/// </summary>
/// <param name="url">调用的URL</param>
/// <param name="paraData">参数</param>
/// <param name="encoding">编码格式(传空为默认的编码)</param>
/// <returns></returns>
public static string PostData(string url, string paraData, Encoding encoding)
{
if (string.IsNullOrEmpty(paraData))
{
return string.Empty;
}
try
{
byte[] dataPara = UTF8Encoding.UTF8.GetBytes(paraData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = dataPara.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(dataPara, , dataPara.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader strRead = null;
if (encoding != null)
{
strRead = new StreamReader(response.GetResponseStream(), encoding);
}
else
{
strRead = new StreamReader(response.GetResponseStream());
}
string result = strRead.ReadToEnd();
newStream.Close();
strRead.Close();
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion #region 接收post
private string PostInput(HttpContext context)
{
try
{
System.IO.Stream s = context.Request.InputStream;
int count = ;
byte[] buffer = new byte[];
StringBuilder builder = new StringBuilder();
while ((count = s.Read(buffer, , )) > )
{
builder.Append(Encoding.UTF8.GetString(buffer, , count));
}
s.Flush();
s.Close();
s.Dispose();
return builder.ToString();
}
catch (Exception ex)
{ throw ex; }
}
#endregion } public class JsonModel
{
public string A { get; set; }
public string B { get; set; }
public string C { get; set; }
public string D { get; set; }
public string E1 { get; set; }
public string E2 { get; set; }
public string E3 { get; set; }
public string F { get; set; }
public string G { get; set; }
public string H { get; set; }
public string I { get; set; }
public string J { get; set; }
public string K { get; set; }
public string L { get; set; }
public string M1 { get; set; }
public string M2 { get; set; }
public string M3 { get; set; }
public string M4 { get; set; }
public string N { get; set; }
public string N1 { get; set; }
public string O { get; set; }
public string P { get; set; }
public string Q { get; set; }
public string R { get; set; }
public string S { get; set; }
public string T { get; set; }
public string U { get; set; }
public string X { get; set; }
public string Y { get; set; }
public string Z { get; set; }
} /// <summary>
/// 结果信息
/// </summary>
public class ResultMSG
{
public string message { get; set; }
public string htNO { get; set; }
public DateTime htCreatTime { get; set; }
public string htRemark { get; set; }
public DateTime htEndTime { get; set; }
public int htEndKM { get; set; }
public float htMoney { get; set; }
public string htContractKey { get; set; }
}

 

c#_1:后台post请求的更多相关文章

  1. Flask04 后台获取请求数据、视图函数返回类型、前台接受响应数据

    1 后台获取请求数据 1.1 提出问题 前台发送请求的方式有哪些 后台如何获取这些请求的参数 1.2 前台发送请求的方式 GET.POST.AJAX 点睛:如果不指定请求方式,浏览器默认使用GET请求 ...

  2. 后台web请求代码(含https,json提交)

    后台web请求 namespace XXXX.Utilites { using System; using System.Collections.Generic; using System.IO; u ...

  3. node后台fetch请求数据-Hostname/IP doesn't match certificate's altnames解决方法

    一.问题背景 基于express框架,node后台fetch请求数据,报错Hostname/IP doesn't match certificate's altnames..... require(' ...

  4. aes加解密后续问题contentType不是application/json时候后台解析请求对象request

    一.post请求的三种content-type 1.application/x-www-form-urlencoded 主要用于如下:1.1: 最常见的POST提交数据方式.1.2:原生form默认的 ...

  5. ajax 请求成功,但是后台feigin请求超时解决方案

    ========后台请求数据时间较长,报feigin超时错误====== fegin报错如下: feign.RetryableException: Read timed out executing P ...

  6. 利用SPM工具运行自己创建的小组件(使用common-model向后台接口请求数据)

    步骤如下: 1.安装依赖:spm install -e 2.编译:spm build (编译好的东西会放在trunk-dist里面) 3.发布:spm app -d (会出来一个export端口,一般 ...

  7. JavaScript当页面关闭时向后台发送请求

    今天做项目时遇上一个需求,当浏览器或页面关闭时将数据存储到数据库内.实现思想是采用js监测onunload然后发送请求.结果失败,刷新可以发送但是关闭并不能,整了一整天并没有解决,最后找到了解决办法. ...

  8. 后台模拟请求 HttpHelper 序列化 MD5 时间戳

    使用场景 C# 服务器后台调用其他服务器并处理 场景 /// <summary> /// 获取用户信息 /// </summary> /// <param name=&q ...

  9. java后台发送请求并获取返回值(续)

    在java后端发送请求给另一个平台,从而给前端实现 "透传"的过程中,出现:数据请求到了并传到了前端,但是控制台打印时中文显示Unicode码而前端界面中中文显示不出来!!!开始怀 ...

随机推荐

  1. oracle 9i相关问题

    Oracle 9i在连接数据库的时候需要加上双引号,如sqlplus “sys/oracle@orcl as sysdba” Oracle 9i不支持bigfile大的表空间创建,oracle9i或以 ...

  2. c++ DLL->DEF->LIB

    一.DLL->DEF https://support.microsoft.com/zh-cn/kb/177429 https://msdn.microsoft.com/zh-cn/library ...

  3. C# 文件压缩加解密

    1.这种方式也可以做到对文件的加密压缩,解密解压缩,只是在压缩和解压缩时会出现压缩窗口 1.1加密压缩 strzipPath:压缩包路径 strtxtPath:待压缩的文件路径 password:加密 ...

  4. echarts 用marlkline画线 同时配置中含有datazoom,怎么设置markline

    由于项目需要设置边界值即用markline 画标线,通过echarts文档可以查看到(如下) 1.通过坐标点(xAxis和yAxis的设置) 通过网上搜索许多markline的配置都是通过下面来设置的 ...

  5. UWP学习开发笔记记录(开篇)

    零零散散开发微软移动2年多了,基本上从未记录或写过任何笔记.所以打算写一些自己的心得和技术的分享,大家一起来共同探讨.虽然现在UWP的工作几乎没有了,但是我感觉大家都是在观望,再看接下来微软的动作,所 ...

  6. idea转eclipse 设置注意。

    下载适合的eclipse

  7. paper 118:计算机视觉、模式识别、机器学习常用牛人主页链接

    牛人主页(主页有很多论文代码) Serge Belongie at UC San Diego Antonio Torralba at MIT Alexei Ffros at CMU Ce Liu at ...

  8. 超简单的JNI——NDK开发教程

    不好意思各位,我按照网上一些教程进行JNI开发,折腾了半天也没成功,最后自己瞎搞搞定了,其实超简单的,网上的教程应该过时了,最新版的AS就包含了NDK编译的功能,完全不用手动javah,各种包名路径的 ...

  9. Hadoop: Hadoop Cluster配置文件

    Hadoop配置文件 Hadoop的配置文件: 只读的默认配置文件:core-default.xml, hdfs-default.xml, yarn-default.xml 和 mapred-defa ...

  10. MATLAB的GUI

    % 常使用的对象查看和设置函数 % .get.set函数 ) % 获得句柄值为0的对象的属性,即显示器对象属性 plot([:]); % 绘制一幅图 title('示例'); % 增加text对象 % ...