zoukankan      html  css  js  c++  java
  • .net 接口返回json格式示例

    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 = "1";
                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、效果演示:

    提交

    右键查看源码

  • 相关阅读:
    细菌 状态压缩
    素数
    骑士问题(knight)
    魔法石的诱惑
    平面上的最接近点对
    救援行动(save)
    优先队列
    leetcode 92. 反转链表 II
    leetcode 91. 解码方法
    leetcode 39. 组合总和
  • 原文地址:https://www.cnblogs.com/xw-yanger/p/5139225.html
Copyright © 2011-2022 走看看