asp.net mvc - Correct way to retrieve data from a webapi2.1 header -
I have created a base API controller that allows me to access data from a header. Public Virtual Ink GetHeaderData () {if (request! = Null) {var header = request Header; Int Custom Value; If (header "mycustomvalue") {int.TryParse (headers.GetValues ("mycustomvalue"). First (), custom value out); Return Custom Value; }} New exception throw (); } Therefore calling is very easy with any controller eg. GetHeaderData () However, as a subsidiary, I find this unit very difficult to test request. Headers Am I really trying to read the header value at the controller level or should I do somewhere else that would be able to do this easy test? I'm the best way I should be I would not go away so far to call it a advice, but to consider you just one suggestion First, the unit test should not determine your class design. It is possible to set the request object at the admin level to return the Request.Headers headers to the unit test correctly. H...