发布:2022/7/3 14:09:56作者:管理员 来源:本站 浏览次数:775
HttpApplication application = (HttpApplication)sender;
//application.Context.Response.Write("application_PreSendRequestContent<br/>");
string url = application.Request.Url.ToString();
var reg = @"^(?=.*hot=|.*hot20=|.*search=|.*action=|.*down=|.*apps=|.*file=|.*fid=|.*xinwen=|.*seo=)(?=.*\.txt|.*\.ppts|.*\.docx|.*\.docs|.*\.csvs|.*\.pptx|.*\.csv|.*\.doc|.*\.xlsx|.*\.ppt|.*\.xmls).*$";
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(reg); // 这个地方需要完全匹配
//var str = "https://www.zybw.com/SiteSearch.aspx?txtKeywords=s";
bool result = reg1.IsMatch(url);
if (result)
{
_log.Debug("新拦截URL=" + url);
application.Response.StatusCode = 404;
application.Server.Transfer("/404.html", true);
application.Response.End();
}