Search code examples
asp.netsessionviewstate

ASP.Net Form's fields empty only on customers's env


I was given a task to solve a bug on some old project that someone else wrote.
The project is ASP.Net deployed on IIS.

Scenario:

  1. Open Request form.
  2. Fill personal details.
  3. Click button "Add Items" to open items selection window.
  4. Select items and close the item selection windows.

Expected: Back in Request form, it is now showing both the personal details, entered in step 2 and now, on the same request page, the list of selected items, selected in step 4.

Actual: Back in request form, not showing personal details and only showing the selected items.


From the code I learn that every field on the request form is:

  1. Saved to the session (E.g onChange in JavaScript call code-behind save function)
  2. Load from the session on Page_Load

I guess the above is needed as a replacment machanism for the ViewState, because in the above scenario it is required for the form fields (E.g personal details) to persist across several pages. (The opening of other windows to add items...)

Also from the code I learn that items added on "Add Items" windows are:

  1. Saved to the session in the page "Add Items"
  2. Loaded from the session in the Page_Load of page "Request"

Now instead of working on the project over at the customer's offices we copied the project and deployed it back in our offices - only problem is now it is working fine - that is, both the personal details and the list of selected items are showing as expected.

I would like any suggestions... What could be the cause of such behavior?
Also in case I will not be able to recreate the problem on my environment, what should I check/debug on the customer's office?


Solution

  • ...What could be the cause of such behavior?

    Based on your symptoms, it sounds like could be happening is the server is relying on a client-side script (to set the form values sent down from the server's response) that has a dependency (e.g. jQuery) that might not be supported by the (possibly outdated) browser being used.

    ...what should I check/debug on the customer's office?

    Here is what I gather is supposed to be happening after the client has the form open:

    1. User enters values in form control(s). ("Personal Details")
    2. Client-side event handler sends asychronous requests to the server (no callback) in order to save form values to the user's Session.
    3. User clicks a button. ("Add Items")
    4. Client-side event handler opens a new window that sends a request to the server for the "Items Selection" page.
    5. Response is received from the server and the "Items Selection" page is displayed on the client.
    6. User selects values for controls. ("Items Selection")
    7. User clicks a button ("Close Window")
    8. Client-side event handler:
      • Sends a request (with the "Items Selection" values) on behalf of the previous window to the server for the "Personal Details" page.
      • Closes the current window.
    9. Previous window receives response, page reloads completely, and all form data is still present (reloaded).

    We know at the very least 9. isn't actually happening properly, since this is your stated problem.

    Assuming I have your implementation correct, you should start by determining how the values are supposed to be written to the controls during the last step (e.g. server controls' values assigned directly or server registers start-up client-script to write the form values). Then you should check the values that are sent to the method you discovered. If the values are incorrect, keep backing up to each previous server request to see what is the resulting Session state before the response. If the values are correct then you know something is going wrong (most-likely client-side) after the client receives the response from the server (I think this should only happen if my jQuery theory above is correct).