Fábio Matte Posted December 21, 2023 Share Posted December 21, 2023 (edited) Good afternoon! I developed an entire system in standalone mode (exe), and configuring it to work on IIS works perfectly, however, I changed it here to generate DLL, which instead of IIS creating a connection for each EXE, it will use the sessions of IIS itself. , but now, the variables were shared between users. I created a DataModule only to store specific variables and functions, but I encountered this problem when using DLL (CGI) in IIS. What would be the recommendation for this not to happen? Edited December 28, 2023 by Fábio Matte Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 21, 2023 Administrators Share Posted December 21, 2023 Hi, How did you created the Data module? You must create it from unigui wizard. Standard Delphi data modules are not compatible with unigui. Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 22, 2023 Author Share Posted December 22, 2023 7 hours ago, Farshad Mohajeri said: Hi, How did you created the Data module? You must create it from unigui wizard. Standard Delphi data modules are not compatible with unigui. Goodnight! I created the Data Module as shown in New Items > uniGUI for Delphi > Data Module (as shown in the image). And inside it you add the system variables and functions, precisely because the datamodule should be one for each user session. So I'm trying to figure out what could be wrong that isn't complying with this requirement. Quote Link to comment Share on other sites More sharing options...
Norm Posted December 22, 2023 Share Posted December 22, 2023 FYI I had exactly the same issue, global variables stored in a unigui data module working as expected but failing when I switched to IIS. I resolved the issue by storing the variables in the MainModule instead. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 22, 2023 Administrators Share Posted December 22, 2023 4 hours ago, Fábio Matte said: Goodnight! I created the Data Module as shown in New Items > uniGUI for Delphi > Data Module (as shown in the image). And inside it you add the system variables and functions, precisely because the datamodule should be one for each user session. So I'm trying to figure out what could be wrong that isn't complying with this requirement. OK. I will check. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 22, 2023 Administrators Share Posted December 22, 2023 2 hours ago, Norm said: FYI I had exactly the same issue, global variables stored in a unigui data module working as expected but failing when I switched to IIS. I resolved the issue by storing the variables in the MainModule instead. Hi, What do you mean by saying "global variables"? Thanks Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 22, 2023 Administrators Share Posted December 22, 2023 6 hours ago, Fábio Matte said: Goodnight! I created the Data Module as shown in New Items > uniGUI for Delphi > Data Module (as shown in the image). And inside it you add the system variables and functions, precisely because the datamodule should be one for each user session. So I'm trying to figure out what could be wrong that isn't complying with this requirement. Please let us know how do access or use these data modules in your app. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 22, 2023 Administrators Share Posted December 22, 2023 Let make it clear that MainModule or DataModule(s) class instances are created separately for each session. However, uniGUI can't create multiple copies of global variables that are placed in a global var declaration. In below image you see a DataModule created using uniGUI wizard. The data module instance (TDataModule1) is created separately for each session, but the variable named GlobalVariable is not replicated for each session and there is only one instance of it for the whole web application. Trying to access it from multiple sessions can lead to serious issues. Quote Link to comment Share on other sites More sharing options...
Norm Posted December 22, 2023 Share Posted December 22, 2023 4 hours ago, Farshad Mohajeri said: Hi, What do you mean by saying "global variables"? Thanks I used the term Global Variables because that is what Fabio used. In my case these were session related private fields residing in a Data Module and accessed as public properties (getters / setters). I found that after I moved my application to IIS the field values were not retained properly. As I said I resolved the issue by moving the fields to the MainModule. Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 22, 2023 Author Share Posted December 22, 2023 4 hours ago, Farshad Mohajeri said: Vamos deixar claro que as instâncias das classes MainModule ou DataModule(s) são criadas separadamente para cada sessão. No entanto, o uniGUI não pode criar múltiplas cópias de variáveis globais colocadas em uma declaração var global. Na imagem abaixo você vê um DataModule criado usando o assistente uniGUI. A instância do módulo de dados (TDataModule1) é criada separadamente para cada sessão, mas a variável chamada GlobalVariable não é replicada para cada sessão e há apenas uma instância dela para toda a aplicação web. Tentar acessá-lo em várias sessões pode levar a problemas sérios. Good Morning Farshad, I'm actually using it the way you exemplified here, so that's why it ended up not working as it should. When I launch it in standalone, it works, but when I take it to IIS, it doesn't. Now I understand why, I'm going to have to redo my routines so that this problem no longer occurs. I'm going to try the tip from user Norma to see if I can get where I need to be, otherwise I'll have to review my routines and variables. Thanks Farshad! Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 22, 2023 Author Share Posted December 22, 2023 36 minutes ago, Norm said: Usei o termo Variáveis Globais porque foi isso que o Fabio usou. No meu caso, esses eram campos privados relacionados à sessão que residiam em um Módulo de Dados e eram acessados como propriedades públicas (getters/setters). Descobri que depois de mover meu aplicativo para o IIS, os valores dos campos não foram retidos corretamente. Como disse resolvi o problema movendo os campos para o MainModule. Good Morning Norma, I'm going to do what you did in your application and try to see if I can get a result. Thanks. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted December 22, 2023 Share Posted December 22, 2023 58 minutes ago, Fábio Matte said: Good Morning Norma, I'm going to do what you did in your application and try to see if I can get a result. Thanks. Hello Fabio, There is a difference between : • A Global variable inside a session (for all forms, units, frames,... attached to this session) http://forums.unigui.com/index.php?/topic/11974-global-variable/&do=findComment&comment=63879 • And a Global variable for all sessions (var on ServerModule) Here, also there is an attention if you will go with Farm Server : http://forums.unigui.com/index.php?/topic/17463-global-object/&do=findComment&comment=95684 Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 26, 2023 Author Share Posted December 26, 2023 On 22/12/2023 at 10:04, Abaksoft said: Olá Fábio, Há uma diferença entre : • Uma variável global dentro de uma sessão (para todos os formulários, unidades, frames,... anexados a esta sessão) http://forums.unigui.com/index.php?/topic/11974-global-variable/&do=findComment&comment=63879 • E uma variável global para todas as sessões (var no ServerModule) Aqui também há uma atenção se você for com Farm Server : http://forums.unigui.com/index.php?/topic/17463-global-object/&do=findComment&comment=95684 Thanks for sharing the posts. I was looking for material like this so that I could study and modify my application here. I'm already adjusting and the variables that I migrated because of your help are already working in IIS, I will continue to migrate the others. Thank you very much @Abaksoft 1 Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 28, 2023 Author Share Posted December 28, 2023 Good evening, I wanted to thank everyone here who helped with this problem. In fact, following the tips from @Abaksoft, @Farshad Mohajeri and @Norm I managed to make UniGUI multi-sessions work using IIS on Windows Server 2019. Now each user is in a session with their global variables, without interfering with each other. See the image, before the values were the same on both connections, now each one has its own data. Thank you so much. 1 1 Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted January 1 Administrators Share Posted January 1 Thanks for the update. Glad to see that your issue is resolved. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.