Hi All,
Recently I've got few issues directed to me with Gateway problems; the most common ones were:
1. Symptom: Gateway got page not found error 404 - Cause: Session is lost
2. Symptom: Gateway does not refresh data - Cause: Data is cached
The first case:
There are a few good reasons why applications loose their session (e.g., web.config is changed; cookies data length exceeds the maximal length allowed and other stuff). One less common cause is a deletion of a directory under the virtual directory root, you can observe this google search results to get some additional info regarding this cause.
Detecting that your session has lost can be easily achieved by adding any control with different states to your form and changing it before the gateway's invocation (e.g., add a TextBox control with no text in on initialization and type some text in it before you perform the operation which causes gateway invocation). If the session is lost, your application will restart and controls state will be initialized (e.g., the TextBox text will be empty again).
Overcoming the directory deletion problem can be achieved by using the ASP.NET built in temporary directory mechanism which provides the application with a directory on which temporary directories can be created and deleted without side effects. Getting this directory on runtime is done by:
string strDir = Path.Combine(HttpRuntime.CodegenDir, "my-root");
By using this directory as a temporary solution, you also gain automatic deletion of all files and folders created during a session by .NET Framework when the session is ended.
The second case:
Caching the written data can often happen when using a gateways; detecting such phenomenon is very easy since the data got back from the gateway the first time will be identical all other next times until the current session ends; also, debugging the gateway will discover that the GatewayHandler and GatewayWriter processing methods are not being called.
All you need to do in order to prevent this kind of caching is command:
HttpContext.Current.Response.Expires = -1;
Before writing a response, that is either in IGatwayHandler.GetGatewayHandler() method or in GatewayWriter.ProcessRequest() method, depending on your gateway implementation type.
Best regard,
Itzik Spitzen