123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.IO;
- namespace Ant.Common
- {
- /// <summary>
- /// 后缀为HTML的,都经这里处理
- /// web.config
- /// <add verb="*" path="*.html" type="DCommon.DHandler"/>
- /// </summary>
- public class DHandlerHTML : IHttpHandler
- {
- public bool IsReusable
- {
- get { return false; }
- }
- /// <summary>
- /// 获取物理路径,判断文件夹中有没有存在这个文件
- /// 不存在的话,就会调用FilterStream类进行创建,并写入内容
- /// 存在的话,就直接显示页面
- /// </summary>
- public void ProcessRequest(HttpContext context)
- {
- HttpRequest request = context.Request;
- HttpResponse response = context.Response;
- string htmlPage = request.Url.AbsolutePath;
- string file = context.Server.MapPath(htmlPage);
- if (!File.Exists(file))
- {
- string aspxPage = DHelper.HtmlToAspx(htmlPage);
- response.Redirect(aspxPage);
- return;
- }
- response.WriteFile(file);
- return;
- }
- }
- /// <summary>
- /// 后缀为HTML的,都经这里处理
- /// web.config
- /// <add verb="*" path="*.html" type="DCommon.DHandler"/>
- /// </summary>
- public class DHandlerIMG : IHttpHandler
- {
- public bool IsReusable
- {
- get { return false; }
- }
- /// <summary>
- /// 获取物理路径,判断文件夹中有没有存在这个文件
- /// 不存在的话,就会调用FilterStream类进行创建,并写入内容
- /// 存在的话,就直接显示页面
- /// </summary>
- public void ProcessRequest(HttpContext context)
- {
- HttpRequest request = context.Request;
- HttpResponse response = context.Response;
- string htmlPage = request.Url.AbsolutePath;
- string file = context.Server.MapPath(htmlPage);
- if (!File.Exists(file))
- {
- response.Redirect("/UpFile/NoImg.jpg");
- return;
- }
- response.WriteFile(file);
- return;
- }
- }
- }
|