.net 接口返回json格式示例
2024-08-26 01:21:06
1、新建 InterfaceTestPro1 项目:
FILE - New - Project... - Web - ASP.NET Web Forms Application
name:InterfaceTestPro1
2、新建 test.ashx 项:
项目右键 - Add - New Item.... - Generic Handler
name:test.ashx
将 ProcessRequest 方法替换成如下代码
context.Response.ContentType = "text/plain";
RspMsg rspMsg = new RspMsg();
string name = context.Request.Form["name"].ToString();
rspMsg.ReturnCode = "";
rspMsg.ReturnMessage = "Welcome " + name;
context.Response.Write(rspMsg.ToString());
3、新建 test.html 项:
项目右键 - Add - New Item.... - HTML Page
name:test.html
代码如下
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form name="form1" method="post" action="test.ashx">
name: <input type="text" name="name" value=""/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
4、效果演示:
提交
右键查看源码
最新文章
- CSS 中 Font-Family 中英文对照表
- UDP收发buffer尺寸对收发包流量的影响
- ubuntu SecureCRT破解
- Spark SQL External Data Sources JDBC官方实现读测试
- vs2015-Azure Mobile Service
- jdk各个版本
- Windows 已在 DImageProcess.exe 中触发一个断点。
- 《火球——UML大战需求分析》(第1章 大话UML)——1.5 小结和练习
- SQLServer 分组查询相邻两条记录的时间差
- nginx的https环境如何配置
- 从送外卖到建站售主机还有共享自行车说起-2017年8月江西IDC排行榜与发展报告
- SpringBoot2.x开发案例之整合Quartz任务管理系统
- python github
- Springboot的日志管理&;Springboot整合Junit测试&;Springboot中AOP的使用
- shell 的条件表达式及逻辑操作符简单介绍
- python接口自动化测试十一:传参数:data与json
- laravel管理员表中的模型
- RSA实现前端数据加密
- R9—R常用函数分类汇总
- Logger.getLogger()和LogFactory.getLog()的区别