Asp.net中的HttpModule和HttpHandler的简单用法
发布日期:2021-05-14 04:37:14 浏览次数:16 分类:博客文章

本文共 1969 字,大约阅读时间需要 6 分钟。

���Asp.net������HttpModule���HttpHandler���������������IIS������������������������������������������������������������������������������������������������������������������������������������

������������HttpModule������������������������������������

using System; using System.Web; namespace MyWebApp {     public class MyHttpModule:IHttpModule     {         public void Init(HttpApplication application)         {             application.BeginRequest+=new EventHandler(application_BeginRequest);         }         public void application_BeginRequest(object sender, EventArgs e)         {             HttpContext context = (sender as HttpApplication).Context;             context.Response.Write("������������������HttpModule���������
"); } #region IHttpModule ������ void IHttpModule.Dispose() { throw new NotImplementedException(); } #endregion } }

���������������������������HttpModule������������������������IHttpModule���������������������������Dispose���������������������������������������������������������web.config������������������������������������������

���������HttpHandler���������������������IHttpHandler���������������������������web.config������������������

using System.Web; using System.Web.Services; namespace MyWebApp {     ///      /// $codebehindclassname$ ���������������     ///      [WebService(Namespace = "http://tempuri.org/")]     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]     public class MyHttpHandler : IHttpHandler     {         public void ProcessRequest(HttpContext context)         {             context.Response.ContentType = "text/plain";             context.Response.Write("������������������HttpHandler������!");         }         public bool IsReusable         {             get             {                 return false;             }         }     } }

���web.config���������������������

���������������������

上一篇:自绘GroupBox控件
下一篇:IBatis.net使用说明

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月18日 04时25分23秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章