Although my .NET Core WebAPI app is deployed in an Azure AppService (Windows) successfully, it always provides 403 error

László Kocsor 0 Reputation points
2024-10-09T07:46:23.71+00:00

I'd like to deploy my first .NET Core Web API in an Azure AppService.
Code written in Visual Studio 2022 using .Net 6.0 and it is running as it should in local environment.
Azure App Service is a windows based AppService.
Using VS 2022, the deployment is also successful everytime.
yet despite all this, the result is always the same: HTTP error 403

  • The code is a very simple routine, it generates a string key, based on some provided parameters. It doesn't use any other resources (such as SQL DB etc)
  • Authentication mode set to 'none' in the code
  • HTTP also allowed for the AppService and no Authentication method specified.

I'm quite newbie, but I think I've already tried everything and can't imagine what could be the reason of this. Hope you can help me.

Developer technologies ASP.NET ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-10-09T17:18:40.07+00:00

    403 means access forbidden. this typically means the app services site is acting as a static file handler. check the the web.config is deployed and configured correctly:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="." inheritInChildApplications="false">
        <system.webServer>
          <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
          </handlers>
          <aspNetCore processPath="dotnet" arguments=".\myapp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
        </system.webServer>
      </location>
    </configuration>
    

    note: on windows the config adds the asp.net core support. you could also just use Linux which does not require a web.config file.

    0 comments No comments

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.