WCF 应用程序 - 需要“应用程序启动"http 和 tcp 绑定的代码 [英] WCF Application - need "app start" code for both http and tcp bindings

查看:30
本文介绍了WCF 应用程序 - 需要“应用程序启动"http 和 tcp 绑定的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WCF 应用程序,需要在应用程序启动时触发一些应用程序初始化代码.目前,代码位于 global.asax.cs 中的 Application_Start 方法中:

I have a WCF application that requires some app initialization code to fire when the app starts. Currently the code sits in my Application_Start method in global.asax.cs:

protected void Application_Start(object sender, EventArgs e)
{
    // Whatever..
}

但是,我的 WCF 应用程序同时具有 http (asp.net) 和 TCP (netTcpBinding) 端点,具体取决于调用的服务.此代码只会为普通的 http 端点触发,而不是 TCP.无论客户端调用是通过 tcp 还是 http 进行的,我都需要启动应用程序启动代码.做到这一点的最佳方法是什么?

However, my WCF app has both http (asp.net) and TCP (netTcpBinding) endpoints, depending on what service is being called. This code will only fire for normal http endpoints, not TCP. I need the app start code to fire regardless of whether a client call was made via tcp or http. What's the best way to do this?

谢谢

推荐答案

Application_Start 仅适用于 HTTP 管道.如果您需要与协议无关的初始化使用 AppInitialize 方法.

Application_Start is only for HTTP pipeline. If you need protocol agnostic initialization use AppInitialize method.

这篇关于WCF 应用程序 - 需要“应用程序启动"http 和 tcp 绑定的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆