错误401:在ASP.NET核心Web API上未经授权

编程入门 行业动态 更新时间:2024-10-25 02:19:06
本文介绍了错误401:在ASP.NET核心Web API上未经授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好 我有一个web api和一个在ASP.NET Core(VS 2017)上开发的网站。该网站在localhost上运行良好,可以调用web api并获得返回。 然后将这两个站点部署到Windows Server 2012 R2,在IIS上运行8.5。我已经关注了很多关于如何为ASP.NET Core配置IIS的文章,我对配置是正确的感到满意。 我可以浏览到这两个URL,没有什么是失败。然而,当网站试图调用web api时,我得到错误401:未经授权 有没有人经历过这个并且可以推荐一个解决方案。 我尝试了什么: 我尝试使用Postman查看我是否可以使用API并返回一些值,调用成功并返回请求的数据。 我查看了文件夹和web api站点站点上的权限。一切看起来都很正常(应该是这样)

Hi All I have a web api and a web site developed on ASP.NET Core (VS 2017). The website works well on localhost and is able to call the web api and get returns. Both of the sites were then deployed to Windows Server 2012 R2, running on IIS 8.5. I have followed numerous articles on how to configure IIS for ASP.NET Core and I am satisfied that the configuration is right. I can browse to both URLs and nothing is failing. However, when the website tries to call the web api I get Error 401: UnAuthorised Has anyone experienced this and can some recommend a solution. What I have tried: I tried using Postman to see if I can reach the API and return some values, the calls were successful and returned the requested data. I looked at the permissions on the folder and on the site of the web api site. Everything looks normal (as it should be)

推荐答案

Helo Kulile, 如果更好的话你已经提到了错误的子代码(如下所示)。 这将有助于解决问题。 401.1:访问被拒绝由于凭据无效。 401.2:由于服务器配置支持备用身份验证方法,访​​问被拒绝。 401.3:由于在请求的资源上设置了ACL,访问被拒绝。 401.4:Web服务器上安装的过滤器授权失败。 401.5:ISAPI / CGI应用程序授权失败。 401.7:Web服务器上的URL授权策略拒绝访问。 Helo Kulile, it would be better if you've mentioned subcode of the error(given below). This will helps in resolving the issue. 401.1: Access is denied due to invalid credentials. 401.2: Access is denied due to server configuration favoring an alternate authentication method. 401.3: Access is denied due to an ACL set on the requested resource. 401.4: Authorization failed by a filter installed on the Web server. 401.5: Authorization failed by an ISAPI/CGI application. 401.7: Access denied by URL authorization policy on the Web server.

Api项目App Startup app.UseMvc(); app.UseAuthentication(); 对此... app.UseAuthentication(); app.UseMvc(); 如果修改此问题已修复 Api project App Startup app.UseMvc(); app.UseAuthentication(); To this... app.UseAuthentication(); app.UseMvc(); if change this issue fixed

更多推荐

错误401:在ASP.NET核心Web API上未经授权

本文发布于:2023-10-29 07:50:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539138.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未经授权   核心   错误   NET   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!