/// <summary> /// The request gate does check the content of the request to check whether the /// land mine is still intact or if it has been triggered by changing the content /// into an unexpected value. /// </summary> /// <param name="clientId"> The client id. </param> /// <param name="request"> The request. </param> /// <returns> The <see cref="bool"/>. </returns> public override bool RequestGate(string clientId, HttpRequestBase request) { // no client id - nothing to do... if (string.IsNullOrEmpty(clientId)) { return(true); } request.ArgumentMustNotBeNull("request"); var cache = HttpRuntime.Cache; var key = "Landmined-" + clientId; if (cache[key] != null) { return(false); } var currentValue = this.RequestArea == RequestArea.Form ? request.Form[this.LandmineName] : this.RequestArea == RequestArea.Header ? request.Headers[this.LandmineName] : this.RequestArea == RequestArea.QueryString ? request.QueryString[this.LandmineName] : string.Empty; if (currentValue == this.ExpectedValue) { return(true); } cache.Add( key, true, // is this the smallest data we can have? null, // no dependencies DateTime.Now.AddSeconds(this.Seconds), // absolute expiration Cache.NoSlidingExpiration, CacheItemPriority.Low, null); // no callback return(false); }