1

I am getting HTTP 400- Header too long error, I have tried most of solution over internet, but none of them seemed to be working (solutions are like adding reg entries, etc).

I have a sample web application which is calling a web api on my system, but I am getting below error in HTTPERR log file:

2019-11-16 16:58:59 ::1%0 1213 ::1%0 80 HTTP/1.1 GET /WebApplication2/api/values - 400 - RequestLength -

Here is my code which is calling the web API:

HttpWebRequest GETRequest = (HttpWebRequest)WebRequest.Create(URL);
GETRequest.Method = "GET";
GETRequest.ContentType = "application/json";
GETRequest.Headers.Add("Authorization", "<Something Big value>");
WebResponse GETResponse = await GETRequest.GetResponseAsync();
sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
narinder
  • 21
  • 1
  • Server's maximum header length can be changed in most servers. Take a look at this question to learn more: https://stackoverflow.com/questions/686217/maximum-on-http-header-values – Zerok Nov 16 '19 at 18:03
  • 1. The 400 Bad Request error is an HTTP status code that means that the request you sent to the website server, often something simple like a request to load a web page, was somehow incorrect or corrupted and the server couldn't understand it. Try to "google" the correct example of requests and required parameters. 2. IIS? Please edit the post more specifically about the language or environment you use. – J A S K I E R Nov 16 '19 at 18:47

1 Answers1

0

It is recommended to capture ETL log via

https://blogs.msdn.microsoft.com/wndp/2007/01/18/event-tracing-in-http-sys-part-1-capturing-a-trace/

Then you could use network monitor to analyze both request payload and etl log. It will help you find the root cause.

Besides, can you find the 400 error in IIS log? Now that the 400 error appear in httperr log. It looks like http.sys blocked the request before it reach IIS server.

If you can find the 400 error in IIS , then you could try to modify the limitation in system.web/httpRuntime and request filter.

If the 400 error only can be found in httperr log. Then you may have to try to make some change in http.sys registry. https://support.microsoft.com/en-us/help/820129/http-sys-registry-settings-for-windows

Please remember to reboot server to activate these registry!

Jokies Ding
  • 3,374
  • 1
  • 5
  • 10