1

Interestingly enough while developing a module on an ASP.NET web app, I've been storing some cached object data in the ViewState, some well defined and some not (ie: declaring them as dynamic and initializing them as ExpandoObject).

This works fine during development on my Windows 10 IIS 10 dev box but once I push this into a Windows Server Core 2016 with IIS 10 (running .NET 4.5, 4.6, 4.7 or 4.8) it doesn't work, I get the System.ArgumentException: Error serializing value 'System.Dynamic.ExpandoObject' of type 'System.Dynamic.ExpandoObject.' ---> System.Runtime.Serialization.SerializationException: Type 'System.Dynamic.ExpandoObject' in Assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable. error.

I was wondering what could be making this work on the local environment and not on the server side given ExpandoObject isn't serializable natively, so wondering how could my local environment be storing these objects in the viewstate and recovering them just fine?

Edit: Actually, all other objects I'm adding to the viewstate are also not marked serializable and are now starting to give problems on the server. How is it possible this works locally considering none of the objects being added to the viewstate are serializable?

Roberto Andrade
  • 1,793
  • 1
  • 21
  • 27

1 Answers1

0

Does your web.config on the server has enableviewstate set to false?

JobesK
  • 347
  • 1
  • 2
  • 6
  • No, it's not specified, so default `true`. It's weird because other native types are persisted just fine (ie: string, long, etc.). Only ExpandoObject and some other non-serializable objects give out errors on the server, but don't locally which is what puzzled me in the first place. – Roberto Andrade Nov 01 '19 at 15:00