WebSocketExample icon indicating copy to clipboard operation
WebSocketExample copied to clipboard

`Exception Thrown: System.ArgumentNullException` when Running the WebSocketExample

Open joshglenn opened this issue 5 years ago • 1 comments

Hi! I was just checking out your WebSocketExample repo. Looks like a great job!

When trying to run the WebSocketExample project, this line triggers a System.ArgumentNullException exception:

if (context.Request.AcceptTypes.Contains("text/html"))

At that point context.request.AcceptTypes is null

Here is the locals window at that point in time:

Screen Shot 2020-04-21 at 11 06 06 AM

joshglenn avatar Apr 21 '20 16:04 joshglenn

Sorry I took so long to reply, I've been heavily tied up on some other projects.

I'm surprised Accept is missing, that's about as basic and standard as headers get in HTTP! Technically there are probably other possible problems in that super-simplified code, for example */* is a common Accept header value, too.

Can you tell me more about the scenario you're testing? I see AppleWebKit in the UserAgent, are you running this on a Mac with Safari maybe? I'm not really set up to test with that, but I just pulled down the code and updated the Kestrel project and the newer console project to .NET 3.1. When I wrote the article I was using Chrome on Win10, and now I've switched to Firefox. Both a browser client and the console project are still working normally.

MV10 avatar Jun 29 '20 15:06 MV10