Running a function on WCF start up

后端 未结 3 401
北荒
北荒 2020-12-13 18:46

I\'m not sure if its possible, but I\'d like to have a function run as soon as a WCF service is started to generate initial cache data. I\'m not worried now about how to imp

3条回答
  •  青春惊慌失措
    2020-12-13 19:03

    The easiest way is to create an App_Code folder underneath your WCF project root, create a class (I'll call it Initializer but it doesn't matter. The important part is the method name) like so:

    public class Initializer
    {
        public static void AppInitialize()
        {
            // This will get called on startup
        } 
    }
    

    More information about AppInitialize can be found here.

提交回复
热议问题