question

RobinMcAninch-3562 avatar image
0 Votes"
RobinMcAninch-3562 asked SamWu-MSFT edited

Web API not found (404) for .net Core development IIS issue

We developed a web api in .net core and deployed it to our test server (hosted in IIS) with no issue. It is callable from Postman and all seemed good. We now have a new server that would be the PROD server Windows 2019 with IIS installed. I added .net core hosting bundle (correct version), create an integrated v4.0 app pool, created the new site (with correct bindings), set up the deployment directory structure like the test box. I next pushed using devops the exact same build that was running on test. The site does not appear to work throwing a 404 for everything - even locally on the box. There are no event viewer errors. To troubleshoot I temporarily allowed directory browsing and added a test.html page to the directory. The IIS logs show the directory browse and the static page are working as expected


IIS Logs result (All Localhost below)

  • Key

Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken



  • Directory
    2021-06-25 19:10:39 ::1 GET / - 44335 - ::1 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 403 14 0 1

test page
2021-06-25 19:02:34 ::1 GET /test.html - 44335 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/91.0.4472.124+Safari/537.36 - 200 0 0 2


this is the unsecured weatherforecast page from the seed project you get with .net core

2021-06-25 19:02:54 ::1 GET /api/v1/weatherforecast - 44335 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/91.0.4472.124+Safari/537.36 - 404 0 2 0

Any other controller method I try gives me 404 errors as well. I looked up the 2 and it is missing file as well. I saw that when I got the box that the ISAPI Filters were only the ASP.Net_2.0.50727.0 and ASP.Net_2.0.50727-64 so I added in the aspnet_filter.dlls for the 4.0.30319 framework but this doesn't seem to have made any difference. There is no other site on this box. I have done multiple IIS resets and restarts and a couple of reboots.

I cannot seem to find anything online that mimics this issue. The site seems up but not responding to .net Core API calls if it renders the basic .html test page. Did I miss installing something beyond the hosting bundle? We have set up about 5 boxes previously and never seen this behaviour.

Thanks in Advance





windows-server-iis
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The forbidden 403 status usually indicates the application identity has not been granted access to the application root and/or web.config file.

It's not clear how you are testing test.html. Is text.html in the application root or is the file within wwwroot and the static file handler is working as expected?

You did not share any configuration. Your routes all use versioning? Your IIS configuration uses port 44335? Not 443?
/api/v1/weatherforecast

0 Votes 0 ·

The 403 is expected because I do not have the directory set up for browsing. I have no routes set up for a default but I added it for illustration. If I type the localhost:44335/index.html into a chrome page on the server, I get the test.html page rendered and the 200 show up in the log. It is just a static page I created in notepad to see I could get anything to render since the API only gives me 404s. The site was created in IIS as a peer to the default site and is listening on port 44335.

The routing for the controller I am trying to test (it is the only one without the authorize tag on it- just to get a response) is
[Route("api/v1/[controller]")].


Thanks

0 Votes 0 ·

Continued.

this site works fine on my test server. The same code is being deployed via devOps to the two boxes but only one works so I think the code is ok. Both servers have:

AppPool v4.0 Integrated using ApplicationPoolIdentity (I tried network Identity but no difference)

The site itself is a peer to Default Web Site
Its bindings are ttps *.44335
The physical path is correct

I mentioned the difference in the ISAPI filters above because that was the only difference I can see between the two sites. The behaviour is as if IIS sees only static pages in the directory. My theory was/is that something didn't get set up properly in IIS but I am grateful for any ideas. Thank you

0 Votes 0 ·

Run a report to learn what's wrong, https://docs.jexusmanager.com/tutorials/ancm-diagnostics.html At least, you chose the wrong application pool settings, because ASP.NET 4.0 shouldn't be used.

0 Votes 0 ·

Thank you for the feedback. Not sure what exactly you mean by the app pool setting being wrong. Everything we have been running for years have all bee .net CLR v4.0 integrated rather than v2.0 classic pipelines. this app is written in .net core 3.1.4 indeed but t seems to work on our test box with the v4.0 app pool.. I appreciate the link and will investigate. I am not sure the firewall rules as they currently stand will allow a diagnostics but I will review the site for ideas.

Thanks.

0 Votes 0 ·

@RobinMcAninch-3562 You can try to use failed request tracking to view detailed error information.


0 Votes 0 ·

Using Failed request tracking shows at file_cache_access_End that the system cannot find the path specified. The Test box that works and the Prod box that doesn't copy files to the same location on their drives. The physical path in the failure is wrong because it pastes the deployed path + the controller routing so it is the install dir + route

Thanks

0 Votes 0 ·

I set up the tracking and was seeing 404s continue. I started to match up the handler mappings with the test server that works as they didn't seem to match. I am now getting 503 errors

The Module DLL %windir5\system32\inetsrv\aspnetcore.dll failed to load. The data is the error.

Which isn't where the dll would installed. this also causes the app pool to crash and stop. Another wrinkle is that the hosting bundle won't fully uninstall and since this was a new box we don't yet have a restore point so I am stuck with this. The app was developed in core 3.1.4 and it seems like IIS is not configured to run it but I cannot figure out why

0 Votes 0 ·

@RobinMcAninch-3562 The file_cache_access_End error is related to NTFS permissions, you can try to set SPN to enable IIS to select the Kerberos protocol for network authentication, please check this article:http://support.microsoft.com/kb/929650. and you can also refer to this link about troubleshooting this error: link.


0 Votes 0 ·

0 Answers