如何自定义IHttpHandler

转载:http://dev.mjxy.cn/a-How-to-customize-the-IHttpHandler.aspx

定义处理HttpHandler 让ModuleX加载的时候稍有延迟。

 public class DelayDownloadHandler :IHttpHandler

    {

        public bool IsReusable

        {

            get { return true; }

        }

        public void ProcessRequest(HttpContext context)

        {

            string path = context.Server.MapPath(context.Request.Path);

            if (context.Request.Path.Contains("ModuleZ"))

            {

                Thread.Sleep(3000);

            }

            context.Response.WriteFile(path);

        }

    }

配置web.config 在httphandler节增加配置

   <httpHandlers>

        <add verb="*" path="*.xap" type="RemoteModuleLoading.Web.DelayDownloadHandler, RemoteModuleLoading.Web"/>

   </httpHandlers>

type=Namespace.Class,AssemblyFile

posted @ 2011-07-14 09:21  敏捷学院  阅读(264)  评论(0编辑  收藏  举报