禁止直接访问ashx页面

  if (context.Request.ServerVariables["HTTP_REFERER"] == null)

            {
                context.Response.Write("NO");
            }
如果直接通过地址栏访问的话,context.Request.ServerVariables["HTTP_REFERER"]为null,如果是ajax发送的get链接,context.Request.ServerVariables["HTTP_REFERER"]为访问链接
 
 
值得纪念的一次探索!
原文地址:https://www.cnblogs.com/uftwkb24/p/7905431.html