Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
509 views
in Technique[技术] by (71.8m points)

asp.net-core - 调用ASP.NET Core 2.1 API时获取401。 这是CORS问题吗?(Getting 401 when calling ASP.NET Core 2.1 API. Is this a CORS issue?)

I've been trying to resolve a 401 error for the past couple days without any success.

(过去几天,我一直在尝试解决401错误,但未成功。)

ASP.NET Core 2.1 API hosted behind IIS.

(IIS背后托管的ASP.NET Core 2.1 API。)

I'm trying to access the API with windows authorisation but I'm being challenged with a login prompt.

(我正在尝试使用Windows授权访问API,但是遇到登录提示的挑战。)

If I don't enter a username and password I get a 401 error (screenshot attached).

(如果我没有输入用户名和密码,则会收到401错误(屏幕截图已附上)。)

I've followed all the articles I could find and believe I have CORS configured correctly.

(我关注了所有可以找到的文章,并相信我已经正确配置了CORS。)

Based on the screenshot does this look like a CORS issue?

(根据屏幕截图,这看起来像是CORS问题?)

I'm testing via swagger and am calling from what I believe is the same domain.

(我正在大摇大摆地进行测试,并且从我认为是同一域的电话中进行呼叫。)

Does anyone have any suggestions regarding what the issue may be?

(是否有人对这个问题有什么建议?)

索取资料

  ask by PatrickNolan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In my case I am getting a 404 for issues related to CORS.

(就我而言,我收到的是与CORS相关的问题的404。)

Note that the browser's console should show a warning in that situation.

(请注意,在这种情况下,浏览器的控制台应显示警告。)

Also be aware that the port is part of the origin, see the docs for details.

(另请注意,端口是源的一部分,有关详细信息,请参阅文档 。)

Maybe this question can help you determining details of the cause of the 401 error.

(也许这个问题可以帮助您确定导致401错误的原因的详细信息。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...