ASP.NET如何防止图片盗连啊
高手说一下好吗

解决方案 »

  1.   

    blackhero(黑侠客)能具体说一下吗
      

  2.   

    我做过,就是用的httpmodule,检查来路判断的。
    给你一个我当时写的类。 public class ModuleDomain:IHttpModule
    {
    public ModuleDomain()
    {}
    public void Init(HttpApplication application)
    {
    application.BeginRequest += new EventHandler(application_BeginRequest);
    application.Error += new EventHandler(application_Error);
    }
    private void application_BeginRequest(Object source,EventArgs e)
    {
    HttpApplication application = (HttpApplication)source;
    HttpContext context = application.Context;
    Regex r = new Regex(@"([0-9a-zA-Z]+\.)freezg\.[com].+");
    string url = context.Request.Url.ToString().ToLower().Replace("http://","");
    if(r.IsMatch(url))
    {
    string userName = url.Substring(0,url.IndexOf("."));
    string lastFile = url.Replace(userName+".freezg.com","");
    string fileName3 = url.Substring(url.LastIndexOf(".")+1);
    string sendToUrl = "";
    if(fileName3 == "gif" || fileName3 == "jpg")
    {
    try
    {
    string referrer = context.Request.UrlReferrer.Host;
    if(!r.IsMatch(referrer))
    {
    context.RewritePath("error.gif");
    return;
    }
    }
    catch
    {}
    }
    if(lastFile == "" || lastFile == "/")
    {
    sendToUrl = @"E:\web\FreeZGUser\"+userName+"\\index.html";
    }
    else
    {
    sendToUrl = @"E:\web\FreeZGUser\"+userName+lastFile;
    }
    context.Response.WriteFile(sendToUrl);
    context.Response.End();
    }
    }
    public void Dispose()
    {} private void application_Error(object sender, EventArgs e)
    {
    HttpApplication application = (HttpApplication)sender;
    HttpContext context = application.Context;
    context.Server.ClearError();
    context.Response.Write("错误,未找到文件");
    context.Response.End();
    }
    }我的Blog:Http://DDotNet.Net
      

  3.   

    还有就是在IIS中和web.config中还要做配置,具体配置问google吧,很多。
      

  4.   

    看看我的名字,知道.net运行原理,就不难了  在isapi作个映射
      

  5.   

    isapi好像要在IIS上设置吧,我是买的空间,能设置吗confei怎 么用流啊
      

  6.   

    1 httphandler or httpmodule
    2 iis添加对图片的映射
    3 所谓的配置webconfig就是添加对 一些图片文件的映射,对一些非本站连接的卢劲要能够在httpmodule过滤
      

  7.   

    对了,你找一个httpmodule的例子看一下就明白了
      

  8.   

    这个 有第三方IIS工具的吧