开发者

Inject/set property in httpmodule on application start

I have a httpmodule that contains a property.

The httpmodule is used in my web application. I want to set the property in the httpmodule when my application starts and not have th开发者_StackOverflowe overhead of setting it everytime the module is called.

The value for the application is read from my app settings in the web.config.

The httpmodule resides in a seperate dll to the web application.

So I want to inject/set the property from my web application on application start.

Any tips as to how I can achieve this?


Well, the application controls the creation and collection of modules, and beyond that IIS maintains a pool of application instances, so I don't think you can just set it once and be done with it.

I think the way to go would be to derive a class from HttpApplication and put your property there. When constructed, the application can read the app setting (meaning the config file access only happens once), and then when modules need it they can get it very efficiently from the Application, without touching the file system.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜