I have been following this link exactly (https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.2&tabs=visual-studio) to create my web api.
**Locally, it is working fine. Tested the links and it returned JSON data
However, once I deploy my web api up to azure app service, all my api links have been returning me error 404. Is there anything that I might have missed out for routing?
In my controller I have added this to my head.
[Route("api/xxx")]
[ApiController]
In each function, I have added this
[HttpPut("xxx/{Id}")]
As for my program/startup it is totally the same as the tutorial
Program class
public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>(); }
Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); }
Let me know if you need anymore information. Really appreciate any help thanks!