//前台提交
<form action="a.ashx" method="post">
<input type="hidden" name="hidden" value="4" />
@x
<input type="submit" value="click" id="@x"/>
</form>
ashx替换@x
string path = context.Request.MapPath("a.html");
string html = System.IO.File.ReadAllText(path);
//判断页面是否是第一次加载
//点击按钮 post
//获取隐藏域的值
string s = context.Request.Form["hidden"];
if (int.TryParse(s, out n))
{
n++;
html = html.Replace("@x", n.ToString());
}
在表单中插入隐藏域的目的在于收集或发送信息,以利于被处理表单的程序所使用。浏览者单击发送按钮发送表单的时候,隐藏域的信息也被一起发送到服务器。