none
Serialization issue in saving WCF cleint in view state RRS feed

  • Question

  • Hi All,

    i have WCF proxy at client end and i have a model defined inside it..

    This model is used to carry the data to the aspx page when i am trying to save this data object into viewstate 

    it thorw back a serlaization issue ..

    Do anyone facecd the similar issue before ?

    any suggestions please.

    Thank you

    Manoj


    Thanks, Manoj

    Saturday, July 27, 2013 6:06 AM

Answers

  • Hi Manoj,

    Would you show some example about the class objects you want to save into ASPX page viewstate?

    ASP.NET ViewState might only accept objects of type which is binary serializable. However, objects coming from WCF is not necessarily binary serializable. WCF could transfer XML serializable or DataContract serializer compatible objects (which might not be binary serializable and cause error to save into ASPX page's viewstate).


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 1, 2013 4:29 PM
    Moderator

All replies

  • Hi,

    The Viewstate can contain only serializable objects.

    Because as the viewstate of a request is passed back to the browser as a serialised representation embedded within the generated page's HTML, it makes sense that only serialisable objects can be placed within it (otherwise it may fail to represent that which it contains.) That viewstate is then de-serialised during the next request.

    Maybe you can store your data in the Session object instead. It depends on what your class does and how it's used.

    Best Regards.


    Amy Peng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Monday, July 29, 2013 3:05 AM
    Moderator
  • Army,

    My Concern was i am finding  issue whil saving the WCF objects into the viewstate 

    I have a model class defined in the proxy and if i save the same object into viewstate then its raising serialization issues...

    If something is cming with proxy class then it is serializable then its should not be a problem in saving it in viewstate right ?

    Manoj


    Thanks, Manoj

    Tuesday, July 30, 2013 8:17 AM
  • Hi Manoj,

    Would you show some example about the class objects you want to save into ASPX page viewstate?

    ASP.NET ViewState might only accept objects of type which is binary serializable. However, objects coming from WCF is not necessarily binary serializable. WCF could transfer XML serializable or DataContract serializer compatible objects (which might not be binary serializable and cause error to save into ASPX page's viewstate).


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 1, 2013 4:29 PM
    Moderator