防盗代码
Uri u = context.Request.UrlReferrer;//访问来源地址 string ip = context.Request.UserHostAddress;//访问来源IP string serverHost = context.Request.Url.Host;//当前访问主机地址 string localIP=System.Configuration.ConfigurationManager.AppSettings["LocalIP"]; if (u == null || u.Host.ToLower() != serverHost.ToLower() || ip != localIP) { context.Response.Write("非本地访问"); } else { context.Response.WriteFile(context.Request.PhysicalPath); }