I am trying to return a 401 (unauthorized) response code from the ASP.NET Web API Web Method (POST), but I get 404. Am I something wrong?
throw new HttpResponseException(HttpStatusCode.Unauthorized); (or set it to HttpResponseMessage)
throw new HttpResponseException(HttpStatusCode.Unauthorized);
thanks
Grrr - the problem was forms authentication, which captures 401 and sends a redirect (302) to the nonexistent login form, so 404. I just needed to set the authentication mode to none in the web.config file.
Source: https://habr.com/ru/post/1411531/More articles:In MonoDevelop, how to disable verbose comment generation as you type /// - xamarin.iosMagento - Products not for sale - magentoCreate dynamic checkboxes and select some of them as indicated. - c #ASP.NET MVC add checkbox dynamically - asp.net-mvcHow to clear and verify ViewModel with MVC? - c #How to prevent Jenkins from checking SVN into the workspace folder when using jobs with multiple configurations - svnhow do I parameterize an event in c # - c #AutoSize ListBox by position height - c #Return a specific HTTP status code in action for a GET request - asp.netStarting sql server job from .net code - c #All Articles