简体   繁体   English

调用WCF方法OnUnload of ASP.NET页面

[英]Call WCF method OnUnload of ASP.NET page

I want call a WCF method when application exit, but, when I try to run ASP.NET application with this code: 我想在应用程序退出时调用WCF方法,但是,当我尝试使用以下代码运行ASP.NET应用程序时:

protected override void OnUnload(EventArgs e)
{
    base.OnUnload(e);

    MaChatServer.Service1Client proxy = new MaChatServer.Service1Client();
    proxy.RemoveUser(UsernameStatic);
    if (proxy.GetAllUsers().Count == 0)
    {
        proxy.ResetServer();
    }
}

I see this error page: 我看到这个错误页面:

Description: An unhandled exception occurred during the execution of the current web request. 描述:执行当前Web请求期间发生未处理的异常。 For more information about the error and where it originated in the code, refer to the stack trace. 有关错误及其在代码中的起源的更多信息,请参阅堆栈跟踪。 Exception Details: System.ServiceModel.FaultException: The server was unable to process the request two to an internal error. 异常详细信息:System.ServiceModel.FaultException:服务器无法将请求2处理为内部错误。 For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. 有关错误的更多信息,请在服务器上启用IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribute或配置行为),以便将异常信息发送回客户端,或者根据Microsoft .NET Framework SDK文档打开跟踪,检查服务器跟踪日志。

Firstly i suggest you to add config to your host wcf service (.config) 首先,我建议您将配置添加到主机wcf服务(.config)

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="debug">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Because you don't have exact error message, your message must be sent to your client 由于您没有确切的错误消息,因此必须将您的消息发送给您的客户

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM