如何 在 继承IhttpModule的 过滤关键字的方法里  在请求页面里弹框 
请问这个功能可以实现吗   如何实现? public void  Init(HttpApplication context)
    {
      context.AcquireRequestState += new EventHandler(context_BeginRequest);
    }    #endregion
    void context_BeginRequest(object sender, EventArgs e)
    {     
        HttpApplication application = (HttpApplication)sender;
        HttpContext context = application.Context;
        Page current = HttpContext.Current.CurrentHandler as Page;
        string key = "";
        if (context.Request.Form != null)
        {
            for (int i = 0; i < context.Request.Form.Count; i++)
            {
                key = context.Request.Form[i];
                if (!FilterText(key))
                {
                    //MessageBox.Show(current, "输入内容包含非法字符");
                    //return;
                    在此弹框                }
            }
        }
    }

解决方案 »

  1.   

    这个好像真不可以    第一  他模块处理完成后  要全部交给handler处理  这样你页面要弹出  就不会能经过handler  这显然是不可能的   没有走handler是肯定不行的   第二   ihttpmoudle 中数据交流  好像采用的是xml传输   那你怎么在xml传输中把你的messagebox.show传过去估计歇菜  
    等待 高手 
      

  2.   


    current.ClientScript.RegisterClientScriptBlock(current.GetType(), "error", "alert('输入内容包含非法字符');", true);
    or
    current.Response.Write("<script>alert('输入内容包含非法字符');</script>");
    current.Response.End();
      

  3.   


    current.Response.Write("<script>alert('输入内容包含非法字符');location.href='error.aspx';</script>");
    current.Response.End();
      

  4.   

    谢谢 Sandy945
    但我试了你的方法 第一个有和没有都一样 依旧提示错误
    下面两个方法提示错误 “响应在此上下文中不可用。”
      

  5.   


    context.Response.Clear();
    context.Response.Write("<script>alert('输入内容包含非法字符');location.href='error.aspx';</script>");
    context.Response.End();
      

  6.   

    还是不行  应该是这个方法应该是在响应前执行的  并没有 Response 
     但Response.Redirect 可以用~  可不可以是页面 请求结束  直接相应本页面啊
      

  7.   

    private   void   context_BeginRequest(object   sender,   EventArgs   e) 

    HttpApplication   app   =   sender   as   HttpApplication; 
    app.CompleteRequest(); 
    app.Context.Response.Write("输入内容包含非法字符"); 

      

  8.   

    context.Response.End();你把这句去了
      

  9.   

    谢谢 人生如梦 和阿菲
    问题解决了 
    application.CompleteRequest();
    application.Context.Response.Write("<script>alert('输入内容包含非法字符');location.href='" + context.Request.FilePath + "'</script>");再次感谢
      

  10.   

    不过 怎么是HttpModuole 只对制定页面判断 不要每个页面都判断呢如有志愿者 我另加分
      

  11.   

    上述问题已解决 现另有一问
    不过 怎样使 HttpModuole 只对制定页面判断 不要每个页面都判断呢如有志愿者 我另加分
      

  12.   

    context.Request.FilePath判断这个就可以了 or context.Request.CurrentExecutionFilePath
      

  13.   


    应该把context.Response.End();这句去掉
      

  14.   

    在Web.config里的httpModules节点 下配置的
    在 不需要验证的页面时  不会去 调用HttpModule类
      

  15.   

    httpModules 节点 是配置不了路径的你只能在 你的实现类中 进行判断