ShineWayCN

WE CONSTRUCT PROFESSIONAL WEB

导航

将 ASPX 页面编译成 DLL

  • 定义由System.Web.IHttpHandler接口派生的自定义类。实现接口中的IsReusableProcessRequest(HttpContext ctxt)成员

    using System.Web;
    using System;
    
    namespace StoT
    {
    //===============
    //start namespace
    //===============
    
    public class Index : IHttpHandler
    {
    
    	public bool IsReusable
    	{
    		get
    		{
    			return true;
    		}
    	}
    
    	public void ProcessRequest(HttpContext ctxt)
    	{
    		HttpRequest rq = ctxt.Request;
    		HttpResponse rp = ctxt.Response;
    		HttpServerUtility sv = ctxt.Server;
    
    		...
    
    		sv=null;
    		rp=null;
    		rq=null;
    	}
    
    }
    
    //=============
    //end namespace
    //=============
    }
    
  • 编译自定义类并输出为StoTIndex.dll文件,把它拷贝至/bin目录下
  • 在web.config配置文件中配置对自定义名字空间和类的引用

    <?xml
    	version="1.0"	?>
    <configuration>
    	<system.web>
    		<globalization
    			fileEncoding="gb2312"
    			requestEncoding="gb2312"
    			responseEncoding="gb2312"	/>
    		<httpHandlers>
    			<add
    				verb="*"
    				path="/stot/index.aspx"
    				type="StoT.Index, StoTIndex"	/>
    		</httpHandlers>
    		<customErrors
    			mode="Off"
    			defaultRedirect="/">
    		</customErrors>
    	</system.web>
    </configuration>
    
  • 这样,凡是对/stot/index.aspx的请求都会由自定义的DLL文件来进行处理了,性能可以提升不少。

posted on 2005-07-17 19:41  ShineWayCN  阅读(856)  评论(0编辑  收藏  举报