How to Troubleshoot 404 error when trying to access api functions in deployed web app. Cannot navigate App service directory for API functions

anthony harmon 0 Reputation points
2024-06-17T14:08:34.9866667+00:00

So for over a month i have been trying to solve the same issue with my azure app service, i deployed it using several different methods to attempt to get different results. this includes the built in azure publish for windows, zip deploy using ftp, filezilla direct file transfer to app service, etc.. and i have spent weeks trying every directory structure me and chatgpt could possibly think of for the app service directories. Ive adjusted the path mappings 1000 times and tried all sorts of configurations for my web.config file. But STILL, everytime i launch my URL, if i point path mapping to the wwwroot that contains my static files it will serve the static files no problem, but will result in a 404 error when trying to interact with the application files in the site root directory. If i point path mappings to the site root with my application files, my API calls will work in postman but it wont serve my static files and gives me a 404 error when trying to access the static files. No matter how many times i've switched things up i get the same errors. I am in need of some expert help

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,082 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,069 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 29,786 Reputation points
    2024-06-17T15:07:39.5233333+00:00

    but will result in a 404 error when trying to interact with the application files in the site root directory. If i point path mappings to the site root with my application files, my API calls will work in postman but it wont serve my static files and gives me a 404 error when trying to access the static files.

    Is this an ASP.NET Core application? If so, it sounds like the static file handler is not configured correctly or does not exist. The Web API Core template does not add a static file handler by default. Make sure the static file handler is registered.

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.