Following this guide https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.1 I decided to use Windows Authentication on my Web API project.
Launching the .Net Core Web API/Site I get a HTTP Error 400.
What is the trick to get .Net Core projects running using Windows Authentication?
After launching the application you will see in the Output Window:
XYZ.API.Core> Content root path: C:\XYZ.API.Core> Now listening on: http://localhost:29002
XYZ.API.Core> Application started. Press Ctrl+C to shut down.
XYZ.API.Core> fail: Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware[0]
XYZ.API.Core> 'MS-ASPNETCORE-TOKEN' does not match the expected pairing token 'de80437e-f80d-4f7f-b2b0-60f3bc81e9b0', request rejected.
So you browse to http://localhost:29002 and get the HTTP 400 Error. The reason is because thats the wrong url for Windows Authenticated.
Open the Properties > launchSettings.json file and notice the IIS settings and application Url uses a different port:
{ "iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iisExpress": {
"applicationUrl": "http://localhost:55403/",
"sslPort": 0
}
Browsing to the applicationUrl specified in the launchSettings file, eg http://localhost:55403/api/values returns the expected json.