简体   繁体   中英

Web API IIS deployment and 403 errors

I have managed to create a deployment package and install it on 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. 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:

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

All other requests are giving 403 forbidden errors. 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.

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; it has .NET 4 and integrated mode for the application pool. I have confirmed that ASP.NET 4.5 is installed via the Add/Remove Windows Features dialog.

The application I am trying to host is based on: https://github.com/MikeWasson/LocalAccountsApp . I have made very minimal changes. Everything works fine locally.

Server stats:

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

So, the underlying issue was I had not set up a https binding for the site. 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.

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