我自己做了一个类实现了IHttpHandler和IRequiresSesssionState接口:public class MyHttpHandler : IHttpHandler, IRequiresSessionState
{
  public void ProcessRequest(HttpContext context)
  {
    usingCount++;
    context.Response.Write(context.Request["ParamThroughGet"]);
    context.Response.Write(context.Request["ParamThroughPost"]);
    context.Response.End();
  }  public bool IsReusable
  {
    get
    {
      return true;
    }
  }
}web.config中配置如下:
<httpHandlers>
 <add verb="*" path="*.agt" type="Trying.MyHttpHandler, MyHttpHandler" />
</httpHandlers>在IIS中加入了文件类型*.agt,指定允许包括GET,POST在内的所有方法,并映射到aspnet_isapi.dll进行处理。客户端页面作了一个静态html进行测试
<html>
 <body>
  <form id="Form1" method="post" action="test.agt?ParamThroughGet=123">
   <input id="ParamThroughPost" type="text">
   <input id="Ok" type="submit">
  </form>
 </body>
</html>结果是:
对于用GET方法提交的参数,MyHttpHandler可以得到参数值(ParamThroughGet),但对于POST方法提交的form中的数据,就得不到了,总是返回null。
请高人指点一下,这是为什么。
谢谢了

解决方案 »

  1.   

    context.Response.Write(context.Form["ParamThroughPost"]);从这个问题看,你做软件有些危险,好大喜功难以成大事。
      

  2.   

    我也跟着你差点翻进去了。应该为:  context.Response.Write(context.Request.Form["ParamThroughPost"]);
      

  3.   

    在ASP.Net里,Request提供的索引器可以直接检索Form和QueryString中的参数,我的这种写法是经过无数次实际检验的。而且用Form["..."]的方法我也试过的,不管用,所以问题应该不是出在这里了。
      

  4.   

    if(context.Request.HttpMethod.ToLower()=="get")
      context.Response.Write(context.Request["ParamThroughGet"]);
    else
    if(context.Request.HttpMethod.ToLower()=="post")
      context.Response.Write(new StreamReader(context.request.InputStream).ReadToEnd());
      

  5.   

    好像表单的input应该用name标识而不是id吧