0

I am trying to set up a custom logfacade project for Nlog, which has two options for setting the configuration.

One is to have all the info in web.config file, the other is to set it up programatically. This would require putting some code in the Application_Start() method in Global.asax.cs. I would however like to not do this, because i would like this logfacade to be as simple as possible to set up.

It should be so simple, that you can just copy a few files into the project, that you need the logfacade in and then add a reference to the logfacade project. And then the only custom setup needed, would be to set a few things in web.config like a connectionstring, filepath or smtp server details for where to do the logging.

TL;DR:

Is it possible in the web.config file, to define some code in a .cs file, that will be run when the application starts up? Without having define anything anywhere else.

Djensen
  • 1,337
  • 1
  • 22
  • 32
  • 1
    [You can use a HttpModule to handle application start event](http://stackoverflow.com/a/3870590/33969) and you can register modules via the web.config. – Reddog Apr 06 '17 at 07:18
  • You cannot attach to the Application_Start event in an HttpModule. Here's a [link of available event](https://support.microsoft.com/en-us/help/307985/info-asp.net-http-modules-and-http-handlers-overview) – Zaheer Ul Hassan Apr 06 '17 at 07:22
  • @Reddog thank you, thats does indeed seem to work as expected. – Djensen Apr 10 '17 at 06:48

0 Answers0