zoukankan      html  css  js  c++  java
  • ASP 用隐藏域解决Http无状态问题

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>
    <body>
        <form method="post" action="SelfAdd.ashx">
            <input type="text" name="num" value="$num" />
            <input type="submit" name="name" value="计算" />
            <input type="hidden" name="hidden" value="$num" />
        </form>
    </body>

    </html>


    <%@ WebHandler Language="C#" Class="SelfAdd" %>


    using System;
    using System.Web;


    public class SelfAdd : IHttpHandler {
        
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/html";
            string filePath = context.Request.MapPath("SelfAdd.html");
            string content = System.IO.File.ReadAllText(filePath);
            int num = Convert.ToInt32(context.Request.Form["hidden"]);
            num++;
            content = content.Replace("$num", num.ToString());
            context.Response.Write(content);
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }


    }

  • 相关阅读:
    bzoj 4260REBXOR
    bzoj 1009GT考试
    cf 621E. Wet Shark and Blocks
    cf 507E. Breaking Good
    cf 766#
    bzoj 3732Network
    bzoj 4300绝世好题
    bzoj 4345[POI2016]Korale
    bzoj 4236JOIOJI
    bzoj 4237稻草人
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434760.html
Copyright © 2011-2022 走看看