public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; context.Response.ContentEncoding = Encoding.UTF8; Stream inputStream = context.Request.InputStream; Encoding encoding = context.Request.ContentEncoding; StreamReader streamReader = new StreamReader(inputStream, encoding); string strJson = streamReader.ReadToEnd(); Param p = JsonConvert.DeserializeObject<Param>(strJson); int top = Convert.ToInt32(p.Top); string term = p.Term; //var result = ... //context.Response.Write(result.ToJson()); } Source Code
jQuery post数据至ashx
今天给大家分享一个小功能,在jQuery环境中,Post data to ashx进行数据交互。
$.ajax({ url: '<%= ResolveUrl("~/Handlers/xxx.ashx") %>', dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify({ top: 10, term: request.term }), success: function (data) { //... } });
jQuery的Post值是使用type: "POST",上传的数据类型为contentType: "application/json; charset=utf-8"。
从代码示例中,它有2个参考需要上传,top,term。
using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary> /// Summary description for Param /// </summary> namespace Insus.NET { public class Param { private int _top; public int Top { get { return _top; } set { _top = value; } } private string _term; public string Term { get { return _term; } set { _term = value; } } } }
在ashx处理程序中,我们可以同下面这样接收Post过来的数据:
下面我们尝试在实际环境中,Post一个数据如 “1628”,在FireFox的firebug看到传送结果如下:
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2024年09月24日
2024年09月24日
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】
- 群星.2021-一生一世电视剧原声带【韶愔音乐】【FLAC分轨】
- [试音碟]iFiQuadDSDSamplerAlbum[24-44,1]WAV
- 姚璎格《发烧女中音音响人声示范碟[紫银合金SQCD]》[正版CD低速原抓WAV+CUE]
- 群星《烈火青春》1988[WAV+CUE]
- 蓝心湄.2000-你开心了湄2CD【SONY】【WAV+CUE】
- 谭咏麟.1989-像我这样的朋友【宝丽金】【WAV+CUE】
- 罗文.2022-大地留着的记号·纪念罗文辞别廿载3CD【环球】【WAV+CUE】
- 670《脆弱敏感小女生》[FLAC/分轨][78.47MB]
- 时代少年团《「叁重楼」演唱会 -「楼间楼」重庆站LIVE》[320K/MP3][278.08MB]