HTTP 403禁止访问:拒绝访问ASP.NET Web API

时间:2022-08-07 00:16:20

I'm getting the following error when running our ASP.NET Web API project on our production server.

在生产服务器上运行ASP.NET Web API项目时出现以下错误。

403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.

403 - 禁止访问:访问被拒绝。您无权使用您提供的凭据查看此目录或页面。

Looking at the IIS 7.0 error logs the underlying error is

查看IIS 7.0错误日志的基础错误是

403.14 - Directory listing denied.

403.14 - 目录列表被拒绝。

I have configured the production server so it has the same settings as the staging server (which works). The authentication, modules, authorization, permissions etc are all identical.

我已经配置了生产服务器,因此它具有与登台服务器相同的设置(可以工作)。身份验证,模块,授权,权限等都是相同的。

Following a suggestion in this thread 403 - Forbidden: Access is denied. ASP.Net MVC I have managed to get it working by adding runAllManagedModulesForAllRequests="true" to my web.config file.

遵循此主题中的建议403 - 禁止访问:访问被拒绝。 ASP.Net MVC我已经设法通过将runAllManagedModulesForAllRequests =“true”添加到我的web.config文件来使其工作。

<modules runAllManagedModulesForAllRequests="true">

Whilst this works I don't see this as a long term solution as it will cause unnecessary load on the server.

虽然这有效但我不认为这是一个长期的解决方案,因为它会在服务器上造成不必要的负担。

So it seems to indicate that something isn't getting loaded that should be getting loaded.

所以它似乎表明某些东西没有被加载应该被加载。

3 个解决方案

#1


0  

Hi @DomBuff you can follow this approach while deploying the application to production environment. 1- Publish the application in release mode. 2- Put your application in inetpub -- wwwrot folder because this folder have administrator rights.

嗨@DomBuff,您可以在将应用程序部署到生产环境时遵循此方法。 1-在发布模式下发布应用程序。 2-将您的应用程序放在inetpub - wwwrot文件夹中,因为此文件夹具有管理员权限。

Hopefully it should run.

希望它应该运行。

#2


0  

We missed deployment configuration, application pool associated with the application not exists. I created an application pool with the same name and this error has gone away.

我们错过了部署配置,与应用程序关联的应用程序池不存在。我创建了一个具有相同名称的应用程序池,此错误消失了。

#3


-1  

The above error will pop up when you do not have the permission to access the folder/web.config file.

当您没有访问文件夹/ web.config文件的权限时,将弹出上述错误。

Try the following

请尝试以下方法

1.In Windows Explorer, locate the web.config file that is associated with the application. 
2.Right-click the web.config file 
3.Click Properties. 
4.Click the Security tab, and then click Edit. 
5.Click Add. 
6.In the Enter the object names to select box, IUSR, click Check Names, and then click OK. 
7.Provide Full control, and then click OK. 
8.In the Web.config Properties dialog box, click OK.

I think it should work .

我认为它应该工作。

#1


0  

Hi @DomBuff you can follow this approach while deploying the application to production environment. 1- Publish the application in release mode. 2- Put your application in inetpub -- wwwrot folder because this folder have administrator rights.

嗨@DomBuff,您可以在将应用程序部署到生产环境时遵循此方法。 1-在发布模式下发布应用程序。 2-将您的应用程序放在inetpub - wwwrot文件夹中,因为此文件夹具有管理员权限。

Hopefully it should run.

希望它应该运行。

#2


0  

We missed deployment configuration, application pool associated with the application not exists. I created an application pool with the same name and this error has gone away.

我们错过了部署配置,与应用程序关联的应用程序池不存在。我创建了一个具有相同名称的应用程序池,此错误消失了。

#3


-1  

The above error will pop up when you do not have the permission to access the folder/web.config file.

当您没有访问文件夹/ web.config文件的权限时,将弹出上述错误。

Try the following

请尝试以下方法

1.In Windows Explorer, locate the web.config file that is associated with the application. 
2.Right-click the web.config file 
3.Click Properties. 
4.Click the Security tab, and then click Edit. 
5.Click Add. 
6.In the Enter the object names to select box, IUSR, click Check Names, and then click OK. 
7.Provide Full control, and then click OK. 
8.In the Web.config Properties dialog box, click OK.

I think it should work .

我认为它应该工作。