Last post Dec 05, 2019 09:17 AM by PatriceSc
Dec 02, 2019 09:58 AM|JoeyWang|LINK
I expand AuthorizationFilterAttribute, and set HttpResponseMessage as below code.
Content = new StringContent(JsonConvert.SerializeObject(responseModel)),
StatusCode = System.Net.HttpStatusCode.Unauthorized
But, when I check browser network, it does not show the specified respond, and shows IIS 401 page instead.
It seems the IIS 401 page cover my specified string by above code.
So, what happened? how to resolve it?
Dec 02, 2019 03:08 PM|bruce (sqlwork.com)|LINK
there is no iis 401 page. generally there is no content with a 401 status. the browser has a default it displays.
Dec 05, 2019 09:17 AM|PatriceSc|LINK
Could it be that your code is not even reached? If using Windows authentication I should be done for you earlier. If seeing really some page in the browser, it might be a 401.2 error (authentication error because of a server side configuration issue).
As I alluded earlier it's a bit hard to help without any context. For now it seems you absolutely want to send back a custom response whatever happens, the problem being perhaps here that the response is handled earlier.
It might be easier to help if we can better grasp what you are trying to do. If it never worked, try maybe the simplest thing first and then be explicit about which enhancements you want or if this is an attempt to solve some issue, discuss directly your
source issue (rather than a solution that you think might solve your problem and that maybe leads in a wrong direction ?)
From your earlier post I suspect Windows authentication doesn't work out of the box for you and that you perhaps try to solve this without having first a good idea of why it doesn't work. Within its limit, Windows authentication is quite easy and basically
just works out of the box (you have a web site and an api site that are both part of your intranet ?)