/// <summary> /// Creates a new FormState instance from the form post of the request of the supplied http context. /// Persists this instance using the /// </summary> /// <param name="context"></param> /// <returns></returns> public static FormState Create(HttpContext context) { FormState result = null; if (context != null && context.Request.Form != null && context.Request.Form.Count != 0) { string id = Guid.NewGuid().ToString(); result = new FormState(id, context.Request.Path, context.Request.Form); _storageProvider.Store(result); } return result; }
/// <summary> /// Constructor. /// </summary> /// <param name="state">The form state to restore.</param> public FormStateRestoreHandler(FormState state) { _state = state; }
/// <summary> /// Puts the supplied FormState into the HttpContext.Items collection. This way it can be accessed from the FormSaverHttpModule. /// </summary> /// <param name="context">The current http context.</param> /// <param name="state">The form state instance.</param> public static void SetCurrent(HttpContext context, FormState state) { if (context != null) context.Items[FormRestoreKey] = state; }
/// <summary> /// Stores the form state using the http cache. /// </summary> /// <param name="formState">The form state to store.</param> public void Store(FormState formState) { HttpRuntime.Cache.Add("FormStateSaver_" + formState.StateId, formState, null, Cache.NoAbsoluteExpiration, StateCacheDuration, CacheItemPriority.Normal, null); }