Ejemplo n.º 1
0
        public static string GetValue(this HttpRequestHeaders headers, string name)
        {
            var values = headers.FindValues(name).ToArray();

            if (values.Length == 0)
            {
                throw new RequestHeaderException($"Cannot find request header '{name}'.");
            }

            if (values.Length > 1)
            {
                throw new RequestHeaderException($"Found request header '{name}' with values '{string.Join(",", values)}' but only one '{name}' value is allowed.");
            }

            return(values[0]);
        }