ASP.NET如何防止图片盗连啊
高手说一下好吗
高手说一下好吗
解决方案 »
- 如何用onkeyup实现对出生日期输入的限定
- 如何运用ASP.NET技术实现系统监控?小妹跪求大侠指点__
- 已经解决了.net 安装问题啦《.net 2003安装失败 Setup Failed on component Setup Runtime Files 》发表时间: 2006-11-5 17:23:32
- 请教一个用sqlClient连接SQL Server2000数据库的问题
- excel 作为数据库的问题
- 关于XML的问题,希望大虾进来看一下
- wincontrol webform 传参数问题
- asp.net 连接 oracle 9i 的问题
- 这种文档怎么做 帮帮忙!
- <asp:HyperLinkColumn 列只能传递一个参数,如果我想传递两个以上的参数该怎麽办?
- 如何在服务器上创建文件夹
- 关于多用户同时上传文件造成文件错乱的问题!!!!!!!!!!!!!!!
给你一个我当时写的类。 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
2 iis添加对图片的映射
3 所谓的配置webconfig就是添加对 一些图片文件的映射,对一些非本站连接的卢劲要能够在httpmodule过滤