ASP.NET - 部署问题 - 通过 Web.Config 启用堆栈跟踪/跟踪侦听器日志以查找内部服务器 500 错误



在本地计算机上部署已编译且没有错误的应用程序后,我收到内部服务器 500 错误。 部署应用程序的服务器具有很高的安全性,因此我需要为每个目录指定读写访问权限。此应用程序使用 Windows 身份验证和 Web 服务通过代理填充下拉框。我认为连接到 Web 服务可能存在问题或文件的读/写安全性问题,或活动目录身份验证存在问题。

我编辑了 web.config,以便它使用以下代码显示有关错误原因的更多信息:

<system.web>
  <customErrors mode ="Off"></customErrors>
  <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  <trace enabled="true" pageOutput="true" />
  <authentication mode="Windows"/>
   <authorization>
    <allow roles="algADMIN_USER" />
    <deny users="*" />        
  </authorization> 
<client>
  <endpoint address="http://63.236.108.91/aCompService.svc" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IAcompService" contract="aComp_ServiceReference.IAcompService"
    name="BasicHttpBinding_IAcompService" />
</client>

我现在收到以下错误:

    500 - Internal server error.
    There is a problem with the resource you are looking for, and it cannot be 
    displayed. 

我想查看带有错误来源的堆栈跟踪。

我应该在 web.config 文件中放入什么,以便它显示完整的堆栈跟踪?

从本地运行到部署,网站上需要更改哪些内容?

更新 - 部署人员解除了一些安全读/写限制,现在我得到了

    Parser Error Message: The connection name 'ApplicationServices' was not found in 
    the applications configuration or the connection string is empty. 

为了消除错误,我删除了在第 72 行声明的 AspNetSqlRoleProvider,并且仍然出现错误。然后,我删除了AspNetWindowsTokenRoleProvider和所有提供者信息并得到以下错误:

    Exception message: Default Role Provider could not be found.  

我们的托管都是远程完成的,但服务器人员可以远程登录到本地网络服务器。看起来服务器人员没有将文件发布在正确的位置。现在,我现在收到错误:

    There is a problem with the resource you are looking for, and it cannot 
    be displayed.

关于如何解决这些问题的任何想法?

感谢您的观看!

您是否在

应用程序的文件夹层次结构中的其他位置有一个 web.config,可以覆盖您所做的更改?我以前见过开发人员将 web.config 复制到一个级别以在进行更改时保留它的副本时感到困惑。

这可能是一个令人头疼的根源。

也许使用模拟应该会有所帮助?我在web.config中添加了以下内容:

  <authentication mode="Windows"/>
  <identity impersonate="true"/>

我添加了 WriteToEventLog 代码,以便可以通过该方法跟踪事件日志中的错误。

    Catch Ex As Exception
        WriteToEventLog(Ex.Message, "GetCarriers-Method", EventLogEntryType.Error, "aComp-utility")

    Catch ex As Exception
        WriteToEventLog(ex.Message, "GetMarketingCompanies-Method", EventLogEntryType.Error, "aComp-utility")

也许添加TraceListenerLog应该会有所帮助?

有关此代码的详细信息,请参阅 MSDN。我在web.config中添加了以下内容:

 <configuration>
   <system.diagnostics>
     <trace autoflush="false" indentsize="4">
       <listeners>
         <add name="myListener"
           type="System.Diagnostics.EventLogTraceListener"
           initializeData="TraceListenerLog" />
       </listeners>
     </trace>
   </system.diagnostics>
 </configuration>

我是否也应该默认添加以下内容.aspx.vb?

Overloads Public Shared Sub Main(args() As String)
' Create a trace listener for the event log.
Dim myTraceListener As New EventLogTraceListener("myEventLogSource")
' Add the event log trace listener to the collection.
Trace.Listeners.Add(myTraceListener)
' Write output to the event log.
Trace.WriteLine(myTraceListener)
End Sub 'Main

我能够通过复制我的配置文件然后删除一个段,然后一步一步地测试结果来克服同样的问题。 我发现,在我取下手架后,它工作正常。

最新更新