Sorry, my study notes are not sorted out. I hope you can understand it.
First, because jquery needs to be learned, the ashx file is used to implement Ajax.
The ashx page and webhandler commands instantiate an object derived from ihttphandler. You only need to write the response code in the processrequest method, which is much lighter than the page.
@ Webhandler defines attributes and compilation options for the HTTP handler file (. ashx.
Attribute
ClassSpecifies a class that inherits from ihttphandler. When handler is requested, it is instantiated to respond to the request. This attribute is required
CodebehindIt is useless to specify the file corresponding to the class. It is mainly used to support vs display and can be removed.
Compilation options
DebugThe default value is false, so you do not need to enable it unless debugging. This affects performance and can be omitted.
DescriptionThe description of the current handler is ignored during ASP. NET parsing, and auxiliary information may be provided during debugging, which can be omitted
LanguageThe default value is C #, which can be omitted.
WarningLevelI do not know the default value between 0 and 4. It can be omitted. So about 12 Asp.net
Text Template instruction syntaxSpecifies the settings used when pages and user control compilers process ASP. NET web forms pages (. aspx) and user controls (. ascx) files. See the following: http://msdn.microsoft.com/zh-cn/library/xz702w3e.aspx
. AshxFile is used to write web handler. It is actually a hybrid file with HTML and C. Of course, you can use the. aspx file suffix. Using. ashx allows you to focus on programming without having to worry about related web technologies .. Ashx must contain isreusable. See the following example.
<% @ webhandler language="C#" class="AverageHandler" %>
using System; using System.Web; public class AverageHandler : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext ctx) { ctx.Response.Write("hello"); } }
For isreusable, refer to the following article http://blog.csdn.net/aabbcczy/article/details/3352860
Is an instance that can be reused by other requests to improve efficiency.
When you want to access your session from ashx or httphandler, you must implement the ireadonlysessionstate interface.
Code:
using System;using System.Web;using System.Web.SessionState;public class DownloadHandler : IHttpHandler, IReadOnlySessionState{ public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext ctx) { ctx.Response.Write(ctx.Session["fred"]); }}
The following resources:
Http://www.cnblogs.com/zgqys1980/archive/2008/03/11/1100863.html
For the working principles of httphandler and httpmodule, refer to the following articles:System. Web namespaceThe above working principle is introduced in detail to realize the ihttphandlerfactory interface class in addition to dynamic creation to implement ihttphandler interface class new instance http://msdn.microsoft.com/zh-cn/library/w7f1y429.aspx
So about[Classic favorites] ASP. NET MechanismHttp://www.cnblogs.com/im/archive/2008/01/30/1058618.htmlhttp://www.cnblogs.com/stwyhm/archive/2006/08/08/470972.htmlhttp://blog.csdn.net/chengfong/article/details/4088530http://www.cnblogs.com/tmfc/archive/2006/09/04/493327.html