views:

25

answers:

0

I'm trying to be clever by allowing a small validation method to be defined "inline" in ASCX templates as an Action<,>, like so:

<%= OnValidation(delegate(FormSubmission form, FormResult errors) {
    // form checks in here, append errors to errors variable if required
}) %>

It actually works a treat, but in order to ensure it can be called during postbacks I need to store the method in the session against that form ID. This also works, up until the point where the app needs to rebuild or references change, then the whole thing crashes out because it can't find "App_Webxxxx" in order to deserialize the methods that are left in the user's session (I guess this wouldn't happen if I was using InProc sessions as clearing my cookies gets rid of the error, but it has to work in SQLServer mode too).

To this end, is there a way to remove those types of items before they cause problems or simply ignore them (the lazy option, I know)? I can't just remove them after they've been run as the user may not submit the form. The best I can think is to do some checking on Application_Start, but I'm not sure if that will even execute, and what to check for.

Any clues very much appreciated!