ViewState variable aborts if workflow is being processed

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  
+3
source share
2 answers

IIS ViewState. Session Application, ViewState - . ViewState, , :

ViewState .

, - .

+1

ViewState. , ViewStateModel aspx, . aspx DLL , ViewState , -.

, , ,

, DLL , . , App_Code

0

All Articles