首页 .NET/Web ASP.NET 2.0 HttpHandler实现对某种文件类型权限保护

ASP.NET 2.0 HttpHandler实现对某种文件类型权限保护

作者:胡同里的砖头 围观群众:1661 更新于:2013-12-19

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
///MyHandler 的摘要说明
/// </summary>
public class MyHandler:IHttpHandler
{
    public void ProcessRequest(HttpContext ctx)//方法名固定
    {
        HttpResponse Response;
        ctx.Response.Write("aa");

    }

}

 <httpHandlers>
        <add verb="*" path="Img/*.jpg" type=" MyHandler" />
      </httpHandlers>

当访问Img文件夹下面的任何jpg图片文件的时候,都拒绝访问打印出"aa"字样

  • 本文标题: ASP.NET 2.0 HttpHandler实现对某种文件类型权限保护
  • 文章分类:【.NET/Web】
  • 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.
留言评论
站点声明:
1、本站【胡同里的砖头】个人博客,借鉴网上一些博客模板,取其各优点模块自行拼装开发,本博客开发纯属个人爱好。
2、所有笔记提供给广大用户交流使用,可转载,可复制,纯个人开发所遇问题锦集记录使用
Copyright © huzlblog.com All Rights Reserved. 备案号:苏ICP备2021056683号-8