I am trying to figure out why the following code failed the null
check and throw the exception after some time, and I am yet to determin what's the reason for the timeout, which I think it is the reason I got the exception message, it's normally happens in the morning next day or after lunch break. But I am still yet able to reliably replicate issue.
var prePage = Page.PreviousPage as BasePage;
if (prePage != null)
{
PageSessionField = prePage.PageSessionField;
}
else
{
throw new Exception("Null previous page session exception.");
}
my first guess it the sessionState
timeout:
<sessionState cookieless="UseCookies" mode="InProc" timeout="20" useHostingIdentity="false" />
But I tried to change the timeout
value to for example minimum number 1
, but it mostly don't throw the exception as expected.
Otherwise, the Application pool settings in IIS: idle timeout and recycling settings all looks OK to me.
Update:
I've managed to replicate the issue by waiting 30 minutes and comes back and refresh the page, and will get the exception caused by
Page.PreviousPage
isnull
.It's looks like timeout is caused by
Owin
code which are useing Cookie authentication.Looks like something to do with AD FS token expired, see my answer for the evidence I gathered.