Hi
I want to make a very very simple Unauthorized 401 error back to my API client from my WEB API but I simply cannot figure it out.
I am getting error messages whatever I try and I have googled for some time but all threads are way overkill for what I want.
I just want something very simple like below but it tells me HTTPResponseMessage cannot be used by a method, so how do I return a simple 401 back to the client without having to use exception filters and middleware, yes I do understand those are preferred methods but this is a learning excersise for me so please humor me with a simple way of doing it directly in the web api controller.
if (ApiKey != "FooBar") { return HttpResponseMessage(Unauthorized); }