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

发布于 2024-11-05 06:51:29 字数 1850 浏览 0 评论 0原文

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

关于如何解决这些问题有什么想法吗?

感谢您的关注!

I am getting a Internal Server 500 error after deploying an application that has compiled without errors on my local machine. The server that the application is deployed on has a ton of security so I need to specify read and write access for every directory. This application uses windows authentication and a web service to populate drop down boxes via a proxy. I think there might be an issue connecting to the web service or an issue with the read/write security on the files, or an issue with the active directory authentication.

I edited the web.config so that it would display more information as to the cause of the error with the following code:

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

I am now getting the following Error:

    500 - Internal server error.

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

I would like to see the stack trace with the source of the error.

What am I supposed to put in the web.config file so it displays the full stack trace?

What needs to be changed on the website from locally run to deployment?

Update- The deployment guy lifted some security read/write restrictions and now I get

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

To get rid of the error, I removed the AspNetSqlRoleProvider declared on Line 72 and still
got an error. I then removed the AspNetWindowsTokenRoleProvider and all the provider info
and got the following Error:

    Exception message: Default Role Provider could not be found.  

Our hosting is done all remotely but the server guy can login to the local webserver remotely. It looks like the server guy didn't post the files in the right place. Now, I now get the error:

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

Any ideas on how to fix these issues?

Thanks for looking!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

愚人国度 2024-11-12 06:51:29

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

这可能会让人头疼。

Do you have a web.config at another location in the application's folder hierarchy that could be overriding the change you're making? I've seen confusion before when devs have copied a web.config up a level to retain a copy of it while making test changes.

That can be a source of much head-scratching.

中二柚 2024-11-12 06:51:29

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

Perhaps using impersonation should help?
I added the following in web.config:

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

I added WriteToEventLog code so that I can track errors in the event log by the method.

    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")

Perhaps adding a TraceListenerLog should help?

Reference MSDN for more info on this code. I added the following in 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>

should i also add the following on 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
长途伴 2024-11-12 06:51:29

我能够通过制作配置文件的副本,然后删除一个片段,然后一次一步地测试结果来克服同样的问题。我发现,在移除处理程序后,它工作得很好。

I was able to over come this same problem by making a copy of my config file and then removing one segment and then testing the results one step at a time. What I discovered is that after I removed my handelers it worked fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文