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

时间:2011-05-06 21:02:58

标签: asp.net web-config stack-trace web-deployment internal-server-error

部署在本地计算机上编译无错误的应用程序后,我收到内部服务器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="alg\ADMIN_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.

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

感谢您的期待!

3 个答案:

答案 0 :(得分:1)

您是否在应用程序的文件夹层次结构中的另一个位置有一个web.config,可以覆盖您正在进行的更改?我之前看到混淆时,开发人员将web.config复制到一个级别,以便在进行测试更改时保留它的副本。

这可能是一个令人头疼的问题。

答案 1 :(得分:1)

也许使用假冒应该有帮助吗? 我在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>

我还应该在default.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

答案 2 :(得分:1)

我能够通过复制我的配置文件然后删除一个段然后逐步测试结果来解决同样的问题。我发现的是,在我移除了我的handelers之后它运行良好。