#region 判断调用Ajax的页面是否是该网站的页面
/// <summary>
/// 判断调用Ajax的页面是否是该网站的页面
/// </summary>
public static bool CheckAjaxInvokeFromCurrentSite(HttpContext context)
{
Uri source = context.Request.UrlReferrer;
if (source == null)
{
return false;
}
else if (source.ToString().IndexOf("fx678") <= 0) //判断是否包含本网站域名地址
{
return false;
}
else
{
if (HttpContext.Current.Request.Url.DnsSafeHost != source.DnsSafeHost)
{
return false;
}
}
return true;
}
/// <summary>
/// 判断调用Ajax的页面是否是该网站的页面
/// </summary>
public static bool CheckAjaxInvokeFromCurrentSite(HttpContext context)
{
Uri source = context.Request.UrlReferrer;
if (source == null)
{
return false;
}
else if (source.ToString().IndexOf("fx678") <= 0) //判断是否包含本网站域名地址
{
return false;
}
else
{
if (HttpContext.Current.Request.Url.DnsSafeHost != source.DnsSafeHost)
{
return false;
}
}
return true;
}
#endregion
此方法只能过滤大部分,如需更严格可考虑绑定固定IP