using System;
using System.Web;namespace CustomHandler
{
public class JpgHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// 获取文件服务器端物理路径
string FileName = context.Server.MapPath(context.Request.FilePath);
// 如果UrlReferrer为空,则显示一张默认的禁止盗链的图片
if (context.Request.UrlReferrer.Host == null)
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile(context.Server.MapPath("~/Error.gif"));
}
else
{
// 如果 UrlReferrer中不包含自己站点主机域名,则显示一张默认的禁止盗链的图片
if (context.Request.UrlReferrer.Host.IndexOf("localhost") > -1 | context.Request.UrlReferrer.Host.IndexOf("xxx.com") > -1 | context.Request.UrlReferrer.Host.IndexOf("baidu.com") > -1 | context.Request.UrlReferrer.Host.IndexOf("google") > -1)
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile(FileName);
}
else
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile(context.Server.MapPath("~/Error.gif"));
[这里加入代码] }
}
} public bool IsReusable
{
get { return true; }
}
}
}本人不会c#,谁能帮我在标红处加入一个异步访问 http://www.xxx.com/count.aspx的代码,或c#写入ms sqlserver数据库的完整代码,谢谢!
using System.Web;namespace CustomHandler
{
public class JpgHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// 获取文件服务器端物理路径
string FileName = context.Server.MapPath(context.Request.FilePath);
// 如果UrlReferrer为空,则显示一张默认的禁止盗链的图片
if (context.Request.UrlReferrer.Host == null)
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile(context.Server.MapPath("~/Error.gif"));
}
else
{
// 如果 UrlReferrer中不包含自己站点主机域名,则显示一张默认的禁止盗链的图片
if (context.Request.UrlReferrer.Host.IndexOf("localhost") > -1 | context.Request.UrlReferrer.Host.IndexOf("xxx.com") > -1 | context.Request.UrlReferrer.Host.IndexOf("baidu.com") > -1 | context.Request.UrlReferrer.Host.IndexOf("google") > -1)
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile(FileName);
}
else
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile(context.Server.MapPath("~/Error.gif"));
[这里加入代码] }
}
} public bool IsReusable
{
get { return true; }
}
}
}本人不会c#,谁能帮我在标红处加入一个异步访问 http://www.xxx.com/count.aspx的代码,或c#写入ms sqlserver数据库的完整代码,谢谢!
直接访问http://www.xxx.com/count.aspx?之前看到需要知道是哪个网站盗用的,现在只要计数吗?
HttpWebRequest request= (HttpWebRequest)WebRequest.Create("http://www.xxx.com/count.aspx");
request.BeginGetResponse(null,null);