1

I've created an ISAPI Extension in Delphi which works just fine, but I am wondering if there is a best practice on how to store configuration settings? I can think of a number of ways to do this, but I would of course like to do it the best way. I might have looked in all the wrong places, but I can't find anything that helps me out...

Is an ini or xml file in the same directory as the dll a good way? Or use the windows registry? Or is is possible (and sensible) to put ISAPI Extension-specific configuration in web.config and thereby utilize the IIS Manager to configure? Or something else?

dahook
  • 280
  • 2
  • 14
  • 1
    Thinking "in the box": it could even be configured through an external application which posts the initial configuration information through HTTP ... – mjn Jun 26 '14 at 13:39

2 Answers2

2
  1. You can use an INI file (make sure it's outside the \InetPub\ folder. Make sure you cache the INI file using TMemIniFile.

  2. You can use a XML file. Make sure you read the XML file to cache and release the file handler after that, to prevent locked files during a concurrent read.

To check for changes while the ISAPI is loaded, check the Date/Time stamp of the XML file before re-reading it again.

  1. Another suggestion is to use an in-memory database and load/save the data file to and from disk.
buttercup
  • 1,096
  • 16
  • 37
2

I generally use GetModuleFileName(HInstance); to find out where the DLL is stored, and keep a file there (ini or xml). It's advisable to keep it, and the DLL, out of reach of IIS so it's not accessible over a URL.

Stijn Sanders
  • 35,982
  • 11
  • 45
  • 67
  • How do you keep the DLL out of reach of IIS? I'm putting it in a virtual directory that is configured in IIS, do you know of a safer way? – dahook Jun 30 '14 at 22:04
  • 1
    *Don't* keep it in a virtual directory that is configured in IIS, but register it as a 'wildcard application mapping': https://duckduckgo.com/?q=wildcard+application+mapping – Stijn Sanders Jul 01 '14 at 06:41
  • In ancient times it looked like this: http://xxm.sourceforge.net/tutorial01/index.html#21 – Stijn Sanders Jul 01 '14 at 06:44