Tiny IIS Tip

time to read 2 min | 220 words

Yesterday I wrote a long post and lost it because my session has timed out and I had no warning. Today I got a question about this subject, how to move a client browser to a logout page when their client expires.

The solution for this is very easy, actually (but won't help losing work because of a session timeout, unfortantely), you can use this command in the HTML:

<META HTTP-EQUIV="Refresh" CONTENT="1170; URL=/logout.aspx">

This requires work, though, and can get a little tedious after a while. But what I found is that you can set IIS to send it automatically on all requests, so you set it up once, and forget about it. Very simple to setup (Web Site Properties -> Http Headers -> Add), and will work on everything without a single line of code changing.

If you want to prevent users from losing work, you need to use javascript to popup a warning, or make sure that the state is not lost if the client session timed out. (The warning in ati.com site is extremely annoying, for instance).