發(fā)文章
發(fā)文工具
撰寫
網(wǎng)文摘手
文檔
視頻
思維導(dǎo)圖
隨筆
相冊(cè)
原創(chuàng)同步助手
其他工具
圖片轉(zhuǎn)文字
文件清理
AI助手
留言交流
1 using System; 2 using System.Web; 3 4 public class helloZZ : IHttpHandler { 5 6 public void ProcessRequest (HttpContext context) { 7 context.Response.ContentType = "text/plain"; 8 context.Response.Write("你請(qǐng)求的是hello.zz文件"); 9 } 10 11 public bool IsReusable { 12 get { 13 return false; 14 } 15 } 16 17 }
再在a目錄下建立handler.ashx,代碼如下:
<%@ WebHandler Language="C#" Class="MyHandler" %> using System; using System.Web; public class MyHandler : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); } public bool IsReusable { get { return false; } } }
再建立如下的web.config
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="false" targetFramework="4.0" /> <httpHandlers> <add path="hello.zz" verb="*" type="helloZZ"/> </httpHandlers> </system.web> </configuration>
特殊說(shuō)明:
請(qǐng)直接用vs2012打開handler.ashx,右鍵用瀏覽器打開,這樣做的只是為了構(gòu)建一個(gè)web環(huán)境。再請(qǐng)求hello.zz就可以了
來(lái)自: 昵稱10504424 > 《工作》
0條評(píng)論
發(fā)表
請(qǐng)遵守用戶 評(píng)論公約
IHttpModule和IHttpHandler 應(yīng)用筆記
下面代碼示例打印一行文字的WebApplication2.HelloHandler源碼:using System;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using Sy...
ASP.NET 自定義httpmodule于httphandler介紹
ASP.NET 自定義httpmodule于httphandler介紹。在這個(gè)事件之后,ASP.NET 把該請(qǐng)求轉(zhuǎn)發(fā)給適當(dāng)?shù)腍TTP處理程序 PostRequestHandlerExecute...
自定義處理程序
自定義處理程序。1.創(chuàng)建一個(gè)新類(calcHandler類),用于實(shí)現(xiàn)IHttpHandler接口。public void ProcessRequest(HttpContext cx) { ...
ASP.NET讀取網(wǎng)絡(luò)或本地圖片顯示
public class Handler : IHttpHandler { public void ProcessRequest (HttpContext context) { string imgUrl = context.public class Handler : IHttpHandler { public void Proc...
截獲asp.net http輸出流自己做處理,替換html內(nèi)容_站長(zhǎng)域名論壇www.91c...
tw_old = context.//Response原來(lái)的OutPut tw_new = new StringWriter(_content);//一個(gè)StringWriter,用來(lái)獲取頁(yè)面內(nèi)容 var type_rp = context.Response.GetType(); tw_field = t...
一般處理程序
首先你發(fā)現(xiàn) <%@ WebHandler Language="C#" Class="ImageHandler" %>這句話。<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server&qu...
ASP.NET2.0 遍歷文件夾下所有圖片..
后臺(tái)代碼using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.U...
HttpHandler與HttpModule講解
HttpHandler與HttpModule講解HttpHandler對(duì)象必須實(shí)現(xiàn)IHttpHandler接口,在HttpApplication對(duì)象轉(zhuǎn)交要求至HttpHandler對(duì)象時(shí)會(huì)調(diào)用此接...
關(guān)于asp.net中*.ashx類型的文件
關(guān)于asp.net中*.ashx類型的文件。首先,我們要回顧要使用ASHX文件的目標(biāo),我們要做的是在一個(gè)地址中用ASHX文件并動(dòng)態(tài)的返回內(nèi)容。開始:通過(guò)這幾個(gè)步驟你可以添加一個(gè)新的ashx文件:打開你的ASP.NET we...
微信掃碼,在手機(jī)上查看選中內(nèi)容