Hiding .NET Pages from History (Forward and Back Buttons)

Less than one minute read time.

I have mentioned hiding ASP pages from history before in the main blog. See the article "The Forward and Back Buttons in Code".

You need to hide pages occasionally when if they were added to the history it was create nonsensical navigation options. For example you maybe calling a page via a clientside Ajax call or within a subframe. In the .NET API it is very easy to suppress the use in the history.

Just use the method DontAddToHistory() that belongs to the Web Class.

Usage:

this.DontAddToHistory();

It could not be simpler!