gpt4 book ai didi

How to debug server-side execution of web api request?(如何调试Web API请求的服务器端执行?)

转载 作者:bug小助手 更新时间:2023-10-25 09:20:46 32 4
gpt4 key购买 nike



I have made an ASP.NET Web API in C# that uses a third party .dll. It is based on the the standard ASP.NET Web API / C# template.

我用C#编写了一个使用第三方.dll的ASP.NETWeb API。它基于标准的ASP.NET Web API/C#模板。


I have deployed it on Azure.

我已经在Azure上部署了它。


Some test header that just returns hello world is responding fine.

一些只返回Hello World的测试头响应正常。


However, when I call the other header that runs my extensive code, I get an error 500.

然而,当我调用运行我的扩展代码的另一个头时,我得到一个错误500。


Let's say I'm new to this and need guidance. I would like to know how to get a precise idea of where the code fails on the server side? It runs just fine on the local server.

比方说,我是新手,需要指导。我想知道如何准确地了解代码在服务器端失败的位置?它在本地服务器上运行得很好。


Here is the log I'm getting from Azure:

以下是我从Azure获得的日志:



  1. 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.

  2. IIS was not able to access the web.config file for the Web site or application. This can occur if

  3. the NTFS permissions are set incorrectly.

  4. IIS was not able to process configuration for the Web site or application.

  5. The authenticated user does not have permission to use this DLL.

  6. The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.


Any help is welcomed. Thank you in advance.

欢迎任何帮助。提前谢谢您。


更多回答

si it is deployed on a VM ?

它是否部署在虚拟机上?

You can view detailed error messages by navigating to the log stream and selecting Application Logs: click on portal.azure.com/#home, and click on your site, on the left menu under monitoring click on App service log to enable the logs. Similar thread: stackoverflow.com/questions/36967675/…

您可以通过导航到日志流并选择应用程序日志来查看详细的错误消息:单击portal.azure.com/#home,然后单击您的站点,在监控下的左侧菜单中,单击App服务日志以启用日志。类似的帖子:Stackoverflow.com/Questions/36967675/…

优秀答案推荐

When encountering an HTTP 500 error when calling a specific endpoint of your ASP.NET Web API on Azure, troubleshooting can be a daunting task. However, there is a methodical approach that can assist you in identifying and resolving the issue. Here are the steps to help you diagnose and pinpoint the problem:

当在Azure上调用ASP.NET Web API的特定终结点时遇到HTTP 500错误时,故障排除可能是一项艰巨的任务。然而,有一种有条不紊的方法可以帮助您识别和解决问题。以下是帮助您诊断和定位问题的步骤:


Firstly, check the Azure Application Logs. These logs can help you identify the problem. You can find these logs by going to your App Service on the Azure portal. Once there, under the "Monitoring" section, select "App Service logs." Enable the necessary diagnostic logs, such as "Application Logging," "Failed Request Tracing," and "Detailed error messages." Reproduce the issue, and then check the logs for detailed error messages and stack traces.

首先,检查Azure应用程序日志。这些日志可以帮助您识别问题。你可以通过转到Azure门户上的应用程序服务来找到这些日志。打开后,在“监控”部分下,选择“应用服务日志”。启用必要的诊断日志,如“应用程序日志”、“失败的请求跟踪”和“详细的错误消息”。重现该问题,然后检查日志以了解详细的错误消息和堆栈跟踪。


Next, review your application code, especially the code executed when calling the problematic endpoint. Look for potential issues such as unhandled exceptions, dependencies on third-party DLL, and logging. Adding extensive logging to your code can help track the flow and identify the point where it fails.

接下来,检查您的应用程序代码,特别是在调用有问题的终结点时执行的代码。查找潜在问题,如未处理的异常、对第三方DLL的依赖关系和日志记录。将大量日志记录添加到代码中可以帮助跟踪流并找出它的故障点。


Ensure that your web.config file is correctly configured and deployed to Azure. The error message mentions issues related to web.config, so validate that it's accessible and properly configured. Additionally, verify that the application pool identity in Azure has the necessary permissions to access the required resources, including the DLL and any files or databases your application relies on.

确保已正确配置您的web.config文件并将其部署到Azure。该错误消息提到了与web.config相关的问题,因此请验证它是否可访问且配置正确。此外,请验证Azure中的应用程序池标识是否具有访问所需资源(包括DLL和您的应用程序依赖的任何文件或数据库)所需的权限。


Make sure any external dependencies or required components are installed and configured correctly on Azure. If the issue remains unresolved, consider setting up remote debugging on Azure. This will allow you to attach a debugger to your running Azure application and inspect variables and code execution in real time. This can be a powerful way to identify the root cause of the error.

请确保在Azure上正确安装并配置了任何外部依赖项或必需的组件。如果问题仍未解决,请考虑在Azure上设置远程调试。这将允许您将调试器附加到正在运行的Azure应用程序,并实时检查变量和代码执行情况。这可能是确定错误根本原因的有效方法。


Sometimes, a simple restart of your Azure App Service can resolve internal server errors caused by temporary issues. If you're unable to resolve the issue after performing the above steps, consider reaching out to Azure support for assistance. They can help you investigate further and diagnose complex issues.

有时,只需重新启动你的Azure应用服务,就可以解决由临时问题导致的内部服务器错误。如果在执行上述步骤后仍无法解决问题,请考虑联系Azure支持部门寻求帮助。它们可以帮助您进一步调查和诊断复杂的问题。


When debugging in a production environment, be sure to take appropriate precautions as it can potentially expose sensitive information. It's often a good practice to create a staging environment that mimics your production environment closely for testing and debugging purposes. By following these steps and carefully reviewing the logs and code, you should be able to pinpoint the exact cause of the HTTP 500 error on your Azure-hosted ASP.NET Web API.

在生产环境中进行调试时,请务必采取适当的预防措施,因为这可能会暴露敏感信息。为了测试和调试的目的,创建一个与您的生产环境非常相似的试运行环境通常是一种很好的实践。通过遵循这些步骤并仔细查看日志和代码,您应该能够在您的Azure托管的ASP.NET Web API上查明HTTP 500错误的确切原因。


更多回答

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com