asp.net-coreasp.net-core-webapipleskwebapiasp.net-web-api-routing

ASP.NET Core Web API : my api works on localhost but not on my plesk webserver


I have build an ASP.NET Core Web API and it's working fine on my machine testing it with postmann, all is beautiful, but when I put it in production on my plesk web server, it always says error 404 not found.

I have tried to create a sub domain but same thing, I have change the application url in the launchsetting.json file like so and also change the database to the one I have on the server need help please

"profiles": {
    "NHLStatsAndSalaryAPI": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "swagger",           
      "applicationUrl": "https://apinhl.nhldynastypool.com/",      
      "environmentVariables": {
        //"ASPNETCORE_ENVIRONMENT": "Development"
       "ASPNETCORE_ENVIRONMENT": "Production"
      }
    },

Here's my file tree on my web server:

file tree on my webserver

I have tried to build my app when all was working fine on localhost and change the application url to the one on my plesk webserver. I expected to be able to use it the same way I use it on localhost. I have put all the project on the plesk server but still cant use my api at all was working fine in localhost but not on webserver


Solution

  • You should place your files under httpdocs (replacing the already existing web.config file).

    If you do so an [asp.net core] icon should popup in your domain panel and the api will respond as it did in localhost.

    Plesk requires you to put all the deploy files under httpdocs.

    If you dont the app won't start.