最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
IHttpHandlerFactory的使用测试
时间:2008-01-18 编辑:简简单单 来源:一聚教程网
仿照msdn写了一个接管http请求的类,对于aspx文件,可以正常实现功能,但是对于图片文件,比如
*.jpg却不行,找了一些资料也没搞清楚,cs文件和config文件如下:
搞定了,在IIS中指定对.jpg文件的映射
[D:WINDOWSMicrosoft.NETFrameworkv1.1.4322aspnet_isapi.dll]
HandlerFactory.cs
using System;
using System.Web;
namespace Handlers
{
class HandlerFactory : IHttpHandlerFactory
{
public IHttpHandler GetHandler(HttpContext context, string requestType, String url, String pathTranslated)
{
IHttpHandler handlerToReturn;
if("get" == context.Request.RequestType.ToLower())
{
handlerToReturn = new HandlerImg();
}
else if("post" == context.Request.RequestType.ToLower())
{
handlerToReturn = new HandlerImg();
}
else
{
handlerToReturn = null;
}
return handlerToReturn;
}
public void ReleaseHandler(IHttpHandler handler)
{
}
public bool IsReusable
{
get
{
return false;
}
}
}
public class HandlerImg : IHttpHandler
{
public virtual void ProcessRequest(HttpContext context)
{
相关文章
- 如何对比测试云服务器的性能 07-17
- CF手游夏日灵狐使用测试 夏日灵狐好不好 07-15
- ARPG古风仙侠手游九剑魔龙传7月5日祭剑测试 07-03
- CF手游夏日限定手雷测试 夏日手雷强不强 07-03
- 阴阳师小松丸实战测试 变形不会被驱散 06-18
- 阴阳师彼岸花被动技能被封印的实战测试 06-13