I have a case, where my App under IIS is accessed with a parameter passed in the URL, does some processing, sets session timeout to 20min and waits for user input. But when the user makes selection and clicks on the button, the server seemingly starts a new session that no longer has that initial parameter and so the user needs to start all over.
I'm not exactly sure when this first started, but it has been there for a while now. It happens in about 25-75% of runs, not every time, sometimes both the session and the parameter are preserved. IW logs nothing, so I cannot troubleshoot it.
I can see that IIS starts a new process and loads the DLL anew, so there must be something that's crashing it, I was just unable to figure out what so far.
So, I'm trying to figure out a process that would allow me to set that parameter somewhere in the button, so when the user finally clicks it, it would pass it on in some way, even if that's going to create a new session.
I've tried setting this parameter in the button's ExtraTagParams, but as IW is starting a new session, it gets lost. I think I need to be able to add this parameter on the URL generated by the button click - that should do the trick. Is there any way to do this?
Ans also, is there any way to get more logs to see why the IIS is restarting the process? - there's nothing in the Event Viewer and nothing in the
>>I think I need to be able to add this parameter on the URL
>>generated by the button click - that should do the trick.
You could also use cookies to store your params like so
Set value on button click:
...
WebApplication->Response->Cookies->AddCookie("ORG",o,WebApplication->CookiePath,Now() + 365, true, true);
Retrieve value in same session or not:
...
String org = WebApplication->Request->GetCookieValue("ORG");
(04-17-2023, 04:41 PM)MJS@mjs.us Wrote: [ -> ]>>I think I need to be able to add this parameter on the URL
>>generated by the button click - that should do the trick.
You could also use cookies to store your params like so
Ok, thanks, I haven't thought of that. But now that I've tried, it didn't work: when I'm setting it, there's no roundtrip to the browser, so it's never set and then on the button click, the server starts a new session and there's no such cookie there at that point.
Do I need to somehow force the cookie to be sent to the caller? - all this is happening in OnCreate event of the main form, if that's important.
>>..But now that I've tried, it didn't work...
I guess that makes sense as since a session doesn't exist the controls aren't really initialized by IW yet. Maybe adding a ScriptEvents->Values["onClick"] = "document.cookie='NAME=VALUE;...'"; to the submitting button would force the cookie to exist as the new session starts.
(04-17-2023, 06:36 PM)MJS@mjs.us Wrote: [ -> ]>>..But now that I've tried, it didn't work...
I guess that makes sense as since a session doesn't exist the controls aren't really initialized by IW yet. Maybe adding a ScriptEvents->Values["onClick"] = "document.cookie='NAME=VALUE;...'"; to the submitting button would force the cookie to exist as the new session starts.
Nope, did not work either: IW sheds all cookies when it establishes a new session. I see 2 POST's in a row, 1st contains this cookie in the request, but the response sets a new session cookie only and so in the 2nd POST it's all forgotten, only the new session cookie is set. And then my code kicks in and it sees nothing.
I think the main cause of all your problems is the session timeout, no? Why do you let it happen?
Regarding this
>> Ans also, is there any way to get more logs to see why the IIS is restarting the process?
I suspect it is recycling the application pool. You can configure it and add some conditions to the recycling.
I particularly like this option more than the default to recycle at fixed intervals
[
attachment=576]
(04-18-2023, 06:04 AM)Alexandre Machado Wrote: [ -> ]I think the main cause of all your problems is the session timeout, no? Why do you let it happen?
Regarding this
>> Ans also, is there any way to get more logs to see why the IIS is restarting the process?
I suspect it is recycling the application pool. You can configure it and add some conditions to the recycling.
I particularly like this option more than the default to recycle at fixed intervals
Shouldn't be timeout, as I'm setting it like:
IWServerController.SessionTimeout := 20;
Or should it be this instead? -
WebApplication.SessionTimeOut := 20;
But yes, it could just be IIS. Probably not recycling, though - that's 20min by default, it was happening far too frequently. But I did have 2 worker processes configured here, was testing something else, so now that I brought it down to the default 1, I could not reproduce this issue easily anymore, still testing...
it should be like this:
IWServerController.SessionTimeout := 20;
if all your sessions have the same timeout.
(04-18-2023, 07:58 PM)Alexandre Machado Wrote: [ -> ]it should be like this:
IWServerController.SessionTimeout := 20;
if all your sessions have the same timeout.
Ok, good, that's what I had.
No, they are much smaller, here I'm setting it to 20min, because I'm waiting for user input, as an exception.