How to fix ASP.NET Core with angular API 500 Internal Server Error when uploading file in Development Environment in azure app Service

Jithu Sebastian 0 Reputation points
2023-09-27T15:11:44.74+00:00

I am trying to upload a file to the wwwroot folder, but it shows an API status code 500 internal server error in the development environment. It works on my local machine but not in my development environment.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,688 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
351 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,057 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 68,311 Reputation points
    2023-09-27T17:55:47.29+00:00

    wwwroot should only have static files. a request for a static file should not get a 500 error, unless your asp.net core app is crashing at startup. better explain your issue.

    note: most bundlers add a guid to a file or include in the bundle file, so updating a single file in wwwroot is suspect.

    0 comments No comments

  2. SnehaAgrawal-MSFT 21,926 Reputation points
    2023-10-03T09:55:46.39+00:00

    @Jithu Sebastian Thanks for reaching here!

    There could be several reasons for the 500 Internal Server Error when uploading a file to the wwwroot folder in the development environment of Azure App Service. Here are some steps you can take to troubleshoot the issue:

    1. Check the logs: You can check the logs of your app service to see if there are any errors or exceptions being thrown. You can access the logs from the Azure portal by going to your app service, selecting "Log stream" from the menu, and then selecting "Application logs". This will show you the logs in real-time. You can also download the logs for further analysis.
    2. Check the file permissions: Make sure that the folder you are trying to upload the file to has the correct permissions. You can check the permissions by going to the Kudu console for your app service. To access the Kudu console, go to your app service in the Azure portal, select "Advanced tools" from the menu, and then select "Go". This will take you to the Kudu console. From there, you can navigate to the wwwroot folder and check the permissions.
    3. Check the file size: Make sure that the file you are trying to upload is not too large. There are limits on the size of files that can be uploaded to Azure App Service. You can check the limits for your app service plan in the Azure portal.
    4. Check the code: Make sure that your code is handling the file upload correctly. You can check the code to see if there are any errors or exceptions being thrown. You can also try debugging the code to see where the issue is occurring.

    see- https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-iis-errors-reference?view=aspnetcore-7.0

    Further Azure provides built-in diagnostics to assist with debugging an App Service app. Check this article: how to enable diagnostic logging

    Let us know if further query or issue remains.

    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.