WCF Application - need "app start" code for both http and tcp bindings [duplicate]
Asked Answered
S

1

6

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

Stillman answered 9/1, 2012 at 13:20 Comment(0)
S
6

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

Sylvestersylvia answered 9/1, 2012 at 13:26 Comment(1)
Yup, that's basically it. Remember to set the build action of that file you add to app_code to "content", and it worksStillman

© 2022 - 2024 — McMap. All rights reserved.