I have an IIS application which connects to AF.
During the first call, the following code is executed:
PISystems piSystems = new PISystems(); PISystem piSystem = piSystems["AFSERVERNAME"]; piSystem.Connect(); AFDatabases afDatabases = piSystem.Databases; AFDatabase afDatabase = afDatabases["AFDATABASENAME"]; // Result stored in a static variable, therefore shared between requests/users
This code is executed only once, the afDatabase object is stored in a static variable. All consecutive calls are using the static variable.
Is this a safe approach? Especially when multiple users are connecting to IIS. IIS is configured with pass-through authentication, as shown below.
Note that different users will have access to different AF elements, or some users may not have access to the AF database.
I'm checking the connection using piSystem.ConnectionInfo.IsConnected for each incoming request.
Is this a safe approach? Or should I recall Connect() for each incoming request?