Sending message with 401: Asp.net Web-api
问题 I am in asp.net web API. In login method I check the user/password against the db and if they do not match, I return 401 status code along with invalid user or password method like var content = new StringContent("Invalid user name or password"); var message = new HttpResponseMessage(HttpStatusCode.Unauthorized); message.Content = content; throw new HttpResponseException(message); But API seems to ignore my message and simply return some HTML like <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0