public static void AddCorsHeaders(this HttpResponseMessage response, CorsResult result) { foreach (var item in result.ToResponseHeaders()) { response.Headers.TryAddWithoutValidation(item.Key, item.Value); } }
/// <summary> /// Writes the CORS headers on the response. /// </summary> /// <param name="response">The <see cref="HttpResponseMessage"/>.</param> /// <param name="corsResult">The <see cref="CorsResult"/>.</param> /// <exception cref="System.ArgumentNullException"> /// response /// or /// corsResult /// </exception> public static void WriteCorsHeaders(this HttpResponseMessage response, CorsResult corsResult) { if (response == null) { throw new ArgumentNullException("response"); } if (corsResult == null) { throw new ArgumentNullException("corsResult"); } IDictionary<string, string> corsHeaders = corsResult.ToResponseHeaders(); if (corsHeaders != null) { foreach (KeyValuePair<string, string> header in corsHeaders) { response.Headers.TryAddWithoutValidation(header.Key, header.Value); } } }
private static void WriteCorsHeaders(IOwinContext context, CorsResult result) { IDictionary<string, string> corsHeaders = result.ToResponseHeaders(); if (corsHeaders != null) { foreach (var header in corsHeaders) { context.Response.Headers.Set(header.Key, header.Value); } } }
private void WriteCorsHeaders(CorsResult result, OAuthValidateTokenRequestContext context) { var headers = result.ToResponseHeaders(); if (headers != null) { foreach (var header in headers) { context.Response.Headers.Append(header.Key, header.Value); } } }