1、添加一般应用程序,默认名Handler1.ashx,名字自己更改
2、通过HttpContext.Current.Request.QueryString["参数名"]获取参数
string id = HttpContext.Current.Request.QueryString["id"];
3、整体如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Api_WebForm
{
/// <summary>
/// Handler1 的摘要说明
/// </summary>
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string id = HttpContext.Current.Request.QueryString["id"];
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}