using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Chapter7
{
public class IsPostedFromThisSiteAttribute:AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext.HttpContext!=null)
{
if (filterContext.HttpContext.Request.UrlReferrer==null)
{
throw new System.Web.HttpException("Invalid submission");
}
if (filterContext.HttpContext.Request.UrlReferrer.Host!="localhost")
{
throw new System.Web.HttpException("This form wasnot submitted from this site");
}
}
//base.OnAuthorization(filterContext);
}
}
}