Add class
public class CustomHeaderHandler : DelegatingHandler { protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { return base.SendAsync(request, cancellationToken) .ContinueWith((task) => { HttpResponseMessage response = task.Result; response.Headers.Add("Access-Control-Allow-Origin", "*"); return response; }); } }
and register it in the configuration
var config = new HttpSelfHostConfiguration("http://localhost:5555"); config.MessageHandlers.Add(new CustomHeaderHandler());
source share