1

I work on registration sites as part of my job and patterns appear that I try and farm out to a central BasePage DLL. Here I have created useful and reusable methods in the past, Such as methods to help sending emails and Dependency Injection setups for Ninject.

It might be useful to note that BasePage is a reference that I add to a website.

In this case, I wanted the session to expire, so that when someone uses the browser back event a delegate cannot resubmit their information.

The code I use is:

        // Stop Caching in IE
        Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);

        // Stop Caching in Firefox
        Response.Cache.SetNoStore();

It works, so I thought that it would be useful to have a method in my BasePage class that I could call to Disable the cache, and reduce the call to do this in the page to one line.

The problem is, I think this is partly to do with the fact BasePage is a referenced DLL, if I use the method call from my BasePage dll the cache is not disabled.

Does anyone know if there is a way I can use a call this method from my BasePage dll to disable the cache on a page, or do I have to keep it local to the website?

UPDATE 07/07

Have found something interesting.

Several sites suggest using a session variable to determine if someone is returning to the page. if they are you then fire off to a halt page.

You need the noCache so that the page refires the Page_Load event

But I have also found: I have a page that contains the above mentioned code, but I have a custom validation that has to hit the server to validate and returns a validation error. On correcting, so that the value is valid, then submitting again. Pressing back says the page has expired.

So if I change all the validation so that EnableClientScript is false any error will cause the webserver to time out on a back button event once it has been successfully submitted.

This doesnt fix it completely, but it will stop people pressing back in a specific case of them entering an invalid value.

Cheers

Luke

4

0 回答 0