8.6Enabling standard request headers
Created on Aug 17, 2026~2 min read
To improve the compatibility of network requests sent through the HTTP client and avoid being blocked by a WAF (Web Application Firewall), the framework provides a one-click configuration method to quickly and uniformly set standard request headers:
// Configure for the default clientservices.AddHttpClient(string.Empty, client =>{ // Enable standard request headers client.UseStandardRequestHeaders();});In addition to the global HttpClient configuration, you can also configure specific settings for a single request, as shown below:
HttpRequestBuilder.Get("https://furion.net/") .UseStandardRequestHeaders(); // Enable standard request headersAfter enabling standard request headers, the request automatically adds the following headers:
Accept:application/json,text/plain;q=0.9,*/*;q=0.8(explicit media type priorities to avoid being blocked by aWAF)Connection: enables persistent connections (Keep-Alive) to reduce the overhead of establishing and closingTCPconnections