404 when I deploy an ASP.NET Core Web API
When I deployed an ASP.NET Core Web API to my Azure App Service API App I received a 404 Not Found when the page was opened, as seen in Figure 1.
Figure 1, 404 ASP.NET Core
The reason for this is that the deployment or default ASP.NET Core Web API template does not include a default document in the root directory of the web site. For example, index.htm, defualt.aspx, default.htm are default documents and IIS will deliver them if there is no specific file provided when accessing the URL.
You can place one of those files into the root directory of the web site, in the wwwroot directory or request the ASP.NET Core Web API directly by appending /api/<methodname> or by default add api/values to the end of your ASP.NET Core Web API and you should then get a JSON or XML response as expected.
Comments
- Anonymous
June 03, 2018
Can you explain how can I do that " request the ASP.NET Core Web API directly by appending /api/ or by default add api/values to the end of your ASP.NET Core Web API" ? - Anonymous
September 13, 2018
One of my colleagues, Razvan suggested the following: [Route("/")] [HttpGet] public IActionResult Get2() { var content = "Hello WorldThis is the main page"; return new ContentResult() { Content = content, ContentType = "text/html", }; }- Anonymous
April 28, 2019
Thank you. You saved my day.
- Anonymous