The input string contains non-ASCII or null characters

1k views Asked by At
2016-12-02 02:54:39:180 [WARNING] Microsoft.AspNetCore.Server.Kestrel -    Connection processing ended abnormally
Microsoft.AspNetCore.Server.Kestrel.BadHttpRequestException: The input string contains non-ASCII or null characters.
at Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolIteratorExtensions.GetAsciiString(MemoryPoolIterator start, MemoryPoolIterator end)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame.TakeStartLine(SocketInput input)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
2016-12-02 09:17:10:819 [ERROR] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware - An unhandled exception has occurred: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Gillie.JobCenter.Controllers.WebApi.QuestionnairesController.<SaveConsultant>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.AspNetCore.Mvc.Internal.ObjectMethodExecutor.<CastToObject>d__40`1.MoveNext()

I've got this exception only once, and i can't reproduce. Maybe someone know situations when this error is appears and i will try to reproduce.

1

There are 1 answers

10
BlueMonkMN On

Rather than trying to guess at the input that can cause the error, you should probably be using HTTP log files to see what the actual request looked like. In my experience, staring at code without a really good clue to the source of a problem is unproductive. If you can't easily reproduce the problem, it's unlikely that any amount of guesswork with the code is going to help. You should be approaching the problem from the other end: trying to reproduce it. Identify the input that caused the error.

EDIT: Have you Googled this error message? It looks like others are having problems with Kestrel giving this message due to some bad cookies from the client. It may be a Kestrel bug in cookie handling. Perhaps just logging information about the cookies would be sufficient to identify the problem, and you would not need to log all the POST data. See https://github.com/aspnet/KestrelHttpServer/issues/949

Are you using an old version of Docker for Windows?