User1493956762 posted
I want to restrict my static images from direct url, like www.abc.com/abc.jpg. So to do that, I added a class, inherit IHttpModule and add some lines in web.config. But that class never called.
here is class code
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public class XImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
if (context.Request.UrlReferrer == null ||
context.Request.UrlReferrer.Host.Length == 0 ||
context.Request.UrlReferrer.Host.CompareTo(
context.Request.Url.Host.ToString()) == 0)
{
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
in web.config
<httpHandlers>
<add verb="*" path="*.jpg"
type="XImageHandler" />
<add verb="*" path="*.png"
type="XImageHandler" />
......
</httpHandlers>
any idea ?