简体   繁体   中英

First call to ASP.NET Core 2.0 Web API with Windows authentication on HTTPS always fails in Chrome

I am developing an application with ASP.NET Core 2.0 Web Api backend with Windows authentication and React frontend where I am experiencing that the first call to the API made from the frontend fails with no response (net::ERR_UNEXPECTED).

It seems to me that the 401 challenge response is not delivered or processed correctly by the browser.

This only happens when using Chrome on HTTPS. Using Edge or HTTP it works fine.

Subsequent calls after the first one works fine, and if I refresh the page manually, everything is working. But once I have closed down all Chrome windows and visit the page again, the first call always fails with the same error.

I've managed to reproduce the same behaviour in a fresh ASP.NET Core Web Api application with Windows authentication, where I enabled SSL and only added the following lines in Startup to enable Windows authentication;

services.Configure<IISOptions>(options => options.AutomaticAuthentication = true);
services.AddAuthentication(IISDefaults.AuthenticationScheme);

When accessing the api with the React frontend (with whatwg-fetch), the first call fails with net::ERR_UNEXPECTED.

When navigating to the api through Chrome, a quick flash of an error message can be seen before the page is redirected and shows the correct response.

When accessing the api through Postman, the first call results in a "Could not get any response" message. When trying again, it works. But when I close all Chrome and Postman windows and try again, the first call again shows the "Could not get any response" message.

Am I missing something, or is this some specific behaviour of Chrome?

I've tried hosting the API both in IIS and IIS Express, but there is no difference.

Run this chrome.exe --disable-site-isolation-trials --disable-web-security --user-data-dir="D:\\temp"

Refer : Previous Post - Disable CORS in Chrome

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM