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、效果演示:
提交
右键查看源码