<body>
<form action="Handler1.ashx" method="post">
<input type="hidden" name="_viewstate" value="a" />
<input type="hidden" name="_div" value="@n" />
<!-- <input name="txt" type="text" value="@value" />-->
<!--Session["user"]="bii";-->
<div>@n</div>
<input type="submit" value="click" />
</form>
</body>
public class Handler1 : IHttpHandler,IRequiresSessionState
{
int n = 0;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
HttpRequest request = context.Request;
HttpResponse response = context.Response;
string path = context.Request.MapPath("HtmlPage1.html");
string html = System.IO.File.ReadAllText(path);
//判断页面是否是第一次加载
string viewstate = context.Request.Form["_viewstate"];
string name = request["_viewstate"].ToString();
string pwd = request["_div"].ToString();
string valid_str = "";
if (name!=""&&pwd!="")
{
valid_str = Guid.NewGuid().ToString();
HttpContext.Current.Session["valid"] = valid_str;
}
if(context.Session["valid"] !=null)
{
}
}