I have the following property to save certain page-level information in a ViewState:
protected ViewStateModel Model
{
get
{
if (_pageModel == null)
{
_pageModel = (ViewStateModel) ViewState[_pageModelKey];
if (_pageModel == null)
{
_pageModel = new ViewStateModel();
ViewState[_pageModelKey] = _pageModel;
}
}
return _pageModel;
}
set
{
ViewState[_pageModelKey] = _pageModel = value;
}
}
This works just as well until the IIS workflow processes. I get
Unable to pass object of type 'ViewStateModel' for input 'ViewStateModel
Now, if I am debugging, I see that the ViewState still contains an object of type ViewStateModel with all its values, but if, when comparing its type with my specific Model class, it returns false
// this always returns false if the worker process has been recycled
ViewState[_pageModelKey] is ViewStateModel
shake source
share