I have an asp.net 4.5 application that is a wizard UI that generates a report at the end. I am using the MVC Futures plugin to serialize and pass the model around between forms. I can click all the way through and generate the report. I've also hit F5 and refreshed and it will repost the form data from the previous request and reload the form.
My problem is sometimes, usually after waiting a few minutes, if I try to hit F5 on the page again, instead of it regenerating the report, I get the following error:
SerializationException: Deserialization failed.
It seems to be that the browser may have somehow forgotten the previous request and is trying to refresh the page without resubmitting the form. Any ideas as to what is going on? I will try to reproduce this issue by resubmitting the form right away, then waiting a few minutes and doing it again and watching what gets posted each time, using Fiddler.
Does anybody have any ideas as to what could be the issue here?
Update (1/3/2014):
Here's the post method to generate the report:
[HttpPost]
public ActionResult GenerateReport([Deserialize] WizardModel wizardModel, string providerId = null, string providerName = null)
{
var model = new ReportModel();
if (!String.IsNullOrEmpty(providerId))
{
wizardModel.Providers = new List<NameValue>(){ new NameValue() { Name = providerName, Value = providerId }};
model.AutoPrint = true;
}
var param = new MeasureParams()
{
Key = wizardModel.CriteriaKeys.ToArray(),
ProviderIds = (wizardModel.Providers != null ? wizardModel.Providers.Select(x => x.Value).ToArray() : null),
StartDate = (wizardModel.StartDate),
StartDateAsString = (wizardModel.StartDate).ToString(),
EndDate = (wizardModel.EndDate),
EndDateAsString = (wizardModel.EndDate).ToString()
};
var results = _measureService.CalculateMeasures(param);
model.WizardModel = wizardModel;
model.Results = new List<List<ResultsModel>>();
model.Results.AddRange(MeasureResultsMapper.MapMeasurementsResultToHierarchicalList(results));
if (wizardModel.IsDetailedReport)
{
return View("DetailedReport", model);
}
return View("SummaryReport", model);
}
There's nothing special in the view page itself. It doesn't even have the serialized object. That was in the previous review page. I can post part of that page:
@{ Html.BeginForm("GenerateReport", "Wizard", FormMethod.Post, new {id = "reviewForm"});}
@Html.Serialize("wizardModel", Model)
@{Html.EndForm();}
Full Stack Trace:
Server Error in '/' Application.
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] System.Web.Security.MachineKey.Decode(String encodedData, MachineKeyProtection protectionOption) +268 Microsoft.Web.Mvc.MachineKeyWrapper.Decode(String encodedData, MachineKeyProtection protectionOption) +41 Microsoft.Web.Mvc.MvcSerializer.Deserialize(String serializedValue, SerializationMode mode, IMachineKey machineKey) +175
[SerializationException: Deserialization failed. Verify that the data is being deserialized using the same SerializationMode with which it was serialized. Otherwise see the inner exception.]
Microsoft.Web.Mvc.MvcSerializer.Deserialize(String serializedValue, SerializationMode mode, IMachineKey machineKey) +384
Microsoft.Web.Mvc.MvcSerializer.Deserialize(String serializedValue, SerializationMode mode) +70
Microsoft.Web.Mvc.DeserializingModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +293
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +317
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +117
System.Web.Mvc.Async.<>c_DisplayClass25.b_1e(AsyncCallback asyncCallback, Object asyncState) +446
System.Web.Mvc.Async.WrappedAsyncResult1.Begin(AsyncCallback callback, Object state, Int32 timeout) +130
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +302
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__17(AsyncCallback asyncCallback, Object asyncState) +30
System.Web.Mvc.Async.WrappedAsyncResult
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +130
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +381
System.Web.Mvc.Async.WrappedAsyncResult1.Begin(AsyncCallback callback, Object state, Int32 timeout) +130
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +317
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +15
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__2(AsyncCallback asyncCallback, Object asyncState) +71
System.Web.Mvc.Async.WrappedAsyncResult
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +130
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +249
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +49
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155