2

I have a data entry form that has remote validation set up to check for existing values in the database for a certain field.

Here's what happens:

  1. Go to Create page (data entry form). Enter value X for field.

  2. Field loses focus. Remote validation is called. Fiddler shows the call.

  3. Click Save. Record is saved; page switches to Index page.

  4. Go to Create page again. Enter value Y again for field.

  5. Field loses focus. Remote validation is called (per Fiddler).

  6. Click Save. Record is saved; page switches to Index page.

  7. Go to Create page AGAIN and enter X (again) for field.

  8. Field loses focus. Nothing happens. No call to remote validation (per Fiddler).

  9. Click Save. No call to remote validation. Page attempts to save record but database spits it back.

It's as if the Create page is remembering that a previous value for the field was also X, and not revalidating it since it hasn't changed, even though I've been to other pages in the meantime.

I'm not passing a model to the Create view: I cannot imagine where it's getting the idea that that field has a previous value that's being (or not being) changed.

As far as I can tell, OutputCache is not being used. I'm on IE 8, if it matters.

1
  • 1
    If you found a solution to your problem, you should add your own solution as an answer, and accept it after the delay elapses. Commented Nov 8, 2011 at 16:29

1 Answer 1

4

OK, think I've figured it out. It's not just that you can't use OutputCache to cache your results, you have to explicitly say NOT to cache your validation results. See here for an explanation and example.

ETA: Another thing that can happen is that if the first remote validation call fails (as in, returns a 500 error) it won't get called again. Because of this, if you anticipate your validation routine being called with null data from time to time (because your fields aren't filled in yet) you need to make the parameters nullable and account for that in your validation code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.