Why is IIS not able to access the web.config file

Nils Bezjak 20 Reputation points
2024-09-05T13:05:03.0966667+00:00

Hello,

I recently hosted a web app via Azure App Service and GitHub Actions in Azure. After sending a request to the app service, I got a huge error message in the log stream, which had the following description somewhere inside:

<h3>HTTP Error 500.0 - Internal Server Error</h3><h4>The page cannot be displayed because an internal server error has occurred.</h4></div><div class="content-container"><fieldset><h4>Most likely causes:</h4><ul> <li>IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.</li> <li>IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.</li> <li>IIS was not able to process configuration for the Web site or application.</li> <li>The authenticated user does not have permission to use this DLL.</li> <li>The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.</li> </ul></fieldset></div><div class="content-container"><fieldset><h4>Things you can try:</h4><ul> <li>Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.</li> <li>Check the event logs to see if any additional information was logged.</li> <li>Verify the permissions for the DLL.</li> <li>Install the .NET Extensibility feature if the request is mapped to a managed handler.</li> <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul></fieldset></div><div class="content-container"><fieldset><h4>Detailed Error Information:</h4><div id="details-left"><table border="0" cellpadding="0" cellspacing="0"><tr class="alt"><th>Module</th><td>&nbsp;&nbsp;&nbsp;AspNetCoreModuleV2</td></tr><tr><th>Notification</th><td>&nbsp;&nbsp;&nbsp;ExecuteRequestHandler</td></tr><tr class="alt"><th>Handler</th><td>&nbsp;&nbsp;&nbsp;aspNetCore</td></tr><tr><th>Error Code</th><td>&nbsp;&nbsp;&nbsp;0x00000000</td></tr></table></div><div id="details-right"><table border="0" cellpadding="0" cellspacing="0"><tr class="alt"><th>Requested URL</th><td>&nbsp;&nbsp;&nbsp;https://kvUpdateManager:80/api/product</td></tr><tr><th>Physical Path</th><td>&nbsp;&nbsp;&nbsp;C:\home\site\wwwroot\api\product</td></tr><tr class="alt"><th>Logon Method</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr><tr><th>Logon User</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr></table><div class="clear"></div></div></fieldset></div><div class="content-container"><fieldset><h4>More Information:</h4>This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error.<p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=500,0,0x00000000,14393">View more information &raquo;</a></p><p>Microsoft Knowledge Base Articles:</p></fieldset>

Followed by a stack trace. I tried to look for answers for the past 3 days, but I couldn't find anything. I recreated the app and chatted with our DevOps engineer, but we haven't found anything. Hopefully someone can help. If you need any information, ask away.

I'm using net8.0

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,460 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,684 questions
{count} votes

Accepted answer
  1. JasonPan - MSFT 5,456 Reputation points Microsoft Vendor
    2024-09-06T12:58:43.65+00:00

    Hi @Nils Bezjak,

    Reading the connection string in the asp.net core project is done using the following code.

    builder.Configuration.GetConnectionString("AZURE_SQL");
    

    Source Code

    User's image

    Suggestion
    Since we are using Azure Web App, it is recommend to use connection string feature like below. Here is the official link: Configure connection strings.

    User's image


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Jason

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.