WCF Application - need “app start” code for both http and tcp bindings [duplicate]

邮差的信 提交于 2020-01-13 09:26:06

问题


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

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?

Thanks


回答1:


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



来源:https://stackoverflow.com/questions/8789043/wcf-application-need-app-start-code-for-both-http-and-tcp-bindings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!