I have written a simple .Net Core 3.1 Web Api in Visual Studio 2019 that I'm trying to get working on our test server (Windows Server 2012 R2 running IIS 8.5)
Our server has ASP.Net website and a few WCF services running, where everybody is connecting to the website using https. As this website will need to access this web api, I also need to connect to the api using https, which is where the problems starts showing
up
When I have the http binding is setup like this. Notice that there is no ASP.Net settings. Based on all the guides I have seen, there should be an ASP.Net section, but nobody mentions it so I don't know it it is important
I can call my test method and get the result as expected. This is great as it shows the API is working
But as soon as I add https binding like below, any calls to the API fails. Both when using http and https I will get a "404 - File or directory not found.". The SSL certificate I'm using is the same as the one used for
the website
In the Application Pools I have set it as "No Managed Code", but doesn't really make any difference if I change it
Is it my IIS setup that is wrong or is there something I need in my code to get it working?
You just add the https site binding without removing http and then even http doesn't work any more? This https site binding is not found already on some other site (or maybe on a "catch all" https site ?)
That is correct. If I add https site binding without removing http, then http stops working with the 404 error
The server has a lot of wcf services running, where all of them only has a http binding written like test-servicename.MyWebsiteAddress.com.
Then it has one website with a bit funny binding. There is the normal http and https binding written as test-app.MyWebsiteAddress.com and then it has a https binding where host name field is completely empty and the port is 5 digits (so not the standard
https port). What this empty one does I'm not sure, but I know that if I remove this one the website can't load (Firefox just tells me the connection has timed out) and the same thing happens when I try to call my API
Looks like a binding conflict. If I remember IIS should complain about that if you stop/start the conflicting site and binding rules are a bit more subtle than one could think.
My preference is to always use explicit host header names. If you need further help, I believe https://forums.iis.net/ could be better...
After playing a bit around I can see the issue is IIS, nothing to do with Web API. I'll try to ask on the other board and see if they can help. Thanks for the link
Member
4 Points
23 Posts
Problems getting Web Api running on IIS
Feb 04, 2020 07:15 AM|Adagio_Botjek|LINK
Hi
I have written a simple .Net Core 3.1 Web Api in Visual Studio 2019 that I'm trying to get working on our test server (Windows Server 2012 R2 running IIS 8.5)
Our server has ASP.Net website and a few WCF services running, where everybody is connecting to the website using https. As this website will need to access this web api, I also need to connect to the api using https, which is where the problems starts showing up
When I have the http binding is setup like this. Notice that there is no ASP.Net settings. Based on all the guides I have seen, there should be an ASP.Net section, but nobody mentions it so I don't know it it is important
I can call my test method and get the result as expected. This is great as it shows the API is working
But as soon as I add https binding like below, any calls to the API fails. Both when using http and https I will get a "404 - File or directory not found.". The SSL certificate I'm using is the same as the one used for the website
In the Application Pools I have set it as "No Managed Code", but doesn't really make any difference if I change it
Is it my IIS setup that is wrong or is there something I need in my code to get it working?
All-Star
48670 Points
18169 Posts
Re: Problems getting Web Api running on IIS
Feb 04, 2020 02:33 PM|PatriceSc|LINK
Hi,
You just add the https site binding without removing http and then even http doesn't work any more? This https site binding is not found already on some other site (or maybe on a "catch all" https site ?)
Member
4 Points
23 Posts
Re: Problems getting Web Api running on IIS
Feb 05, 2020 07:33 AM|Adagio_Botjek|LINK
Hi,
That is correct. If I add https site binding without removing http, then http stops working with the 404 error
The server has a lot of wcf services running, where all of them only has a http binding written like test-servicename.MyWebsiteAddress.com.
Then it has one website with a bit funny binding. There is the normal http and https binding written as test-app.MyWebsiteAddress.com and then it has a https binding where host name field is completely empty and the port is 5 digits (so not the standard https port). What this empty one does I'm not sure, but I know that if I remove this one the website can't load (Firefox just tells me the connection has timed out) and the same thing happens when I try to call my API
All-Star
48670 Points
18169 Posts
Re: Problems getting Web Api running on IIS
Feb 05, 2020 08:48 AM|PatriceSc|LINK
Looks like a binding conflict. If I remember IIS should complain about that if you stop/start the conflicting site and binding rules are a bit more subtle than one could think.
My preference is to always use explicit host header names. If you need further help, I believe https://forums.iis.net/ could be better...
Member
4 Points
23 Posts
Re: Problems getting Web Api running on IIS
Feb 05, 2020 09:42 AM|Adagio_Botjek|LINK
After playing a bit around I can see the issue is IIS, nothing to do with Web API. I'll try to ask on the other board and see if they can help. Thanks for the link