I think you probably want to do a null check against the collection. Because your are now passing in request.Headers without checking if it is not null like in the original code.