这两天看了点web Development的面试题,既然有两条路都准备了材料,那就先看用的正在用的.net吧。
先是IIS(Internet Information Service),关于这两个Server的以后再专门写。
IIS 主要跟Windows绑定,这个integration使得DB和OS交接特别迅速,TomCat和Apache特点在于全面OS支持,各有所长。
接着来个问题:What are HttpHandlers and HttpModules in ASP.NET?
首要问题,how does the IIS reacts when a user requests for a particular resource?
1. It looks for the extension of the requested resource file e.g. (.aspx, .ascx etc.). 看后缀
2. It looks for ISAPI extension mapped against this file extension. 马屁ISAPI(Microsoft's Internet Server Application Program Interface)
3. If found a mapping, then pass request to that particular ISAPI extension.交给ISAPI
如下图所示,在到达一个handler之前,有好几个HTTP module会预处理这些所有的文件,如加安全,OutputCache, Session, WindowsAuthentication, FormsAuthentication, RoleManager etc.
现在我们可以回答上面的问题了。
HTTPHandler:
ASP.NET Engine uses HttpHandlers to handle specific requests on the basis of their extensions. ASP.NET Page Handler handles all requests coming for (.aspx) pages. We can define our own custom HttpHandler to handle a specific request with a specific extension, say .jpeg, .gif, or .imran. But there will always be only one handler for a specific request.
HTTPModules:
ASP.NET Engine uses HttpModules to inject some specific functionality alongwith ASP.NET default functionality for all incoming requests regardless of its extensions. There are a number of built-in modules already available in ASP.NET HTTP Pipeline as we discussed earlier. But we can write our own custom HTTP module to perform some additional functionality (for example, URL rewriting or implementing some security mechanism) for all incoming requests.
http://www.webdevelopmenthelp.net/2014/03/httphandlers-and-httpmodules-in-asp-net.html