發(fā)文章
發(fā)文工具
撰寫
網(wǎng)文摘手
文檔
視頻
思維導圖
隨筆
相冊
原創(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("你請求的是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>
特殊說明:
請直接用vs2012打開handler.ashx,右鍵用瀏覽器打開,這樣做的只是為了構(gòu)建一個web環(huán)境。再請求hello.zz就可以了
來自: 昵稱10504424 > 《工作》
0條評論
發(fā)表
請遵守用戶 評論公約
IHttpModule和IHttpHandler 應用筆記
下面代碼示例打印一行文字的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介紹。在這個事件之后,ASP.NET 把該請求轉(zhuǎn)發(fā)給適當?shù)腍TTP處理程序 PostRequestHandlerExecute...
自定義處理程序
自定義處理程序。1.創(chuàng)建一個新類(calcHandler類),用于實現(xiàn)IHttpHandler接口。public void ProcessRequest(HttpContext cx) { ...
ASP.NET讀取網(wǎng)絡或本地圖片顯示
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)容_站長域名論壇www.91c...
tw_old = context.//Response原來的OutPut tw_new = new StringWriter(_content);//一個StringWriter,用來獲取頁面內(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 遍歷文件夾下所有圖片..
后臺代碼using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.U...
HttpHandler與HttpModule講解
HttpHandler與HttpModule講解HttpHandler對象必須實現(xiàn)IHttpHandler接口,在HttpApplication對象轉(zhuǎn)交要求至HttpHandler對象時會調(diào)用此接...
關于asp.net中*.ashx類型的文件
關于asp.net中*.ashx類型的文件。首先,我們要回顧要使用ASHX文件的目標,我們要做的是在一個地址中用ASHX文件并動態(tài)的返回內(nèi)容。開始:通過這幾個步驟你可以添加一個新的ashx文件:打開你的ASP.NET we...
微信掃碼,在手機上查看選中內(nèi)容