public bool VerifyHeader(out string ErrorMsg) { if (AppSettingServiceProvider.UseHeaderVerification == "N" || AppSettingServiceProvider.UseHeaderVerification == "n") { ErrorMsg = " ------ W A R N I N G --------- /r/n ByPass Header Verification!"; return(true); } string ipaddress = "5555555"; StringValues api_Header; StringValues APIKey; var isValidHeader = false; //APIITVendor //VendorData = new APIITVendor(); if (Request.Headers.TryGetValue("APIHeader", out api_Header) && Request.Headers.TryGetValue("APIKey", out APIKey)) { string authHeaderKey = api_Header.First(); string authHeaderToken = APIKey.First(); if (!string.IsNullOrEmpty(authHeaderKey) && !string.IsNullOrEmpty(authHeaderToken)) { //Get Vendor Key and Validate is Key Correct? for (int i = 0; i < KeyAndTokenExtention.KeyAndTokenProvider.Count(); i++) { if (KeyAndTokenExtention.KeyAndTokenProvider[i].ApiHeader == authHeaderKey && KeyAndTokenExtention.KeyAndTokenProvider[i].ApiKey == authHeaderToken) { isValidHeader = true; } } if (!isValidHeader) { ErrorMsg = ipaddress + " :: Missing Authorization Header."; return(false); //BadRequest("Missing Authorization Header."); } } } else { if (!isValidHeader) { //_log.LogDebug(ipaddress + " :: Missing Authorization Header."); ErrorMsg = ipaddress + " :: Missing Authorization Header."; //VendorData = new APIITVendor(); return(false); // return BadRequest("Missing Authorization Header."); } } //VendorData = new APIITVendor(); ErrorMsg = "Header Verify"; return(true); }