简体   繁体   English

Web API IIS部署和403错误

[英]Web API IIS deployment and 403 errors

I have managed to create a deployment package and install it on IIS. 我已经设法创建一个部署程序包并将其安装在IIS上。 It is not serving content correctly. 它不能正确提供内容。

The server responds appropriately when trying to hit URLs that would not be routed to the Web API application, or when the request doesn't make sense. 当尝试访问不会路由到Web API应用程序的URL或请求没有意义时,服务器会做出适当的响应。 For instance, trying to hit a non existent url gives a 404, or making a GET request to a route that only supports POST returns 405 method not allowed with this message: 例如,尝试访问不存在的URL会给出404,或者向仅支持POST的路由发出GET请求,则此消息不允许405方法:

{
   "Message": "The requested resource does not support http method 'GET'."
}

All other requests are giving 403 forbidden errors. 所有其他请求都给出403禁止的错误。 To me, this indicates routing is working correctly and there is some other configuration error. 对我来说,这表明路由工作正常,并且还有其他一些配置错误。 I've tried both the 'bad' and 'good' solutions listed here: http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html , neither made any difference. 我已经尝试了此处列出的“不良”和“良好”解决方案: http : //www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html ,都没有任何区别。

I noticed that the application has not created the user database tables, as it did automatically when I ran the application for the first time. 我注意到该应用程序没有创建用户数据库表,因为它是我第一次运行该应用程序时自动创建的。 I figured this may be related. 我认为这可能是相关的。

I believe IIS is correctly configured; 我相信IIS配置正确; it has .NET 4 and integrated mode for the application pool. 它具有.NET 4和应用程序池的集成模式。 I have confirmed that ASP.NET 4.5 is installed via the Add/Remove Windows Features dialog. 我已经确认通过“添加/删除Windows功能”对话框安装了ASP.NET 4.5。

The application I am trying to host is based on: https://github.com/MikeWasson/LocalAccountsApp . 我尝试托管的应用程序基于: https : //github.com/MikeWasson/LocalAccountsApp I have made very minimal changes. 我所做的改动很小。 Everything works fine locally. 本地一切正常。

Server stats: 服务器统计信息:

  1. Windows Server 2012 R2 Windows Server 2012 R2
  2. SQL Server 2016 SQL Server 2016
  3. IIS 8.5 IIS 8.5

So, the underlying issue was I had not set up a https binding for the site. 因此,根本的问题是我没有为该站点设置https绑定。 This was obscured by a few things, mainly that the endpoints were acting inconsistently. 这被一些事情所掩盖,主要是端点的行为不一致。 One end point was redirected by IIS or Web API to the https binding (presumably because of some setting enforcing it), while another was quite happy to serve me 403/405 errors above. 一个端点被IIS或Web API重定向到https绑定(大概是由于某些设置强制执行),而另一个端点很乐意为我提供上述403/405错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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