0

I have a WebApi project , which returns some data , this works fine when we query through the URL , but returns 401 when i invoke it from my console app. this project has been hosted in IIS 8 and i need this to run under windows authentication. If i set it to anonymous authentication then works fine, but gives error to windows auth mode. Thanks in advance.

3
  • Please include WebApiConfig.cs file in the question.. Commented Apr 26, 2017 at 11:18
  • make sure you have added <authentication mode="Windows" /> under system.web of your application's app.config Commented Apr 26, 2017 at 11:23
  • works fine when we query through the URL , but returns 401 when i invoke it from my console app - is your credentials saved in the browser? try running it under incognito mode and check for the status code. Commented Apr 26, 2017 at 11:24

2 Answers 2

3

Check HTTP Status Codes RFC ...401 stands for Unauthorized Access means while invoking from your console app you are not passing the Authorization header in your API request.

Sign up to request clarification or add additional context in comments.

Comments

1

Check this out(it has info on using windows authentication with web API):

https://www.codeproject.com/tips/996401/authenticate-webapis-with-basic-and-windows-authen

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.