Article From:https://www.cnblogs.com/buchizaodian/p/9496184.html

 

    public class TestHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

 

 

            //Relative path to absolute path
            string path = context.Request.MapPath("/TestHandle.ashx");
            context.Response.Write(path);

 

 request

 1.Gets the value of the get form passed to ashx.

    <form action="TestHandler.ashx" method="get">
        <input type="text" name="user" />
        <input type="password" name="pw" />
        <input type="submit" />
    </form>

 

string str= context.Request.QueryString["user"];

 

2.postrequest

    <form action="TestHandler.ashx" method="post">
        <input type="text" name="user" />
        <input type="password" name="pw" />
        <input type="submit" />
    </form>

back-end

string str="User name:"+context.Request.Form["user"];

 

3.get post Can be obtained.

string str=HttpContext.Current.Request["user"];

 

Link of this Article: General processing program

Leave a Reply

Your email address will not be published. Required fields are marked *