Blog Home  Home RSS 2.0 Atom 1.0 CDF  
The Efficient Coder - JSON Script Ignore Tags
There has got to be a better way of communicating with our computers!
 
 Thursday, June 12, 2008

I've built some ASMX web services (yes these should be converted to WCF, but they work for now).  I'm starting to use these as Script Services for some ASP.NET Ajax Enabled pages.  I ran into a problem where some of the "stuff" I didn't want to have happen in some properties on the objects returned by the server were getting executed even though they were marked as [XmlIgnore()] which disables them for SOAP tASMX type web calls.  Apparently when the returned objects get serialized as JSON for a script service, they ignore the [XmlIgnore()] tag, which I guess makes sense but is rather inconvenient, in that I need to go back and do a manual search & change.  Within the using System.Web.Script.Serialization namespace there is another attribute you can decorate your properties with called [ScriptIgnore()] that seems to do the trick.

-ec

6/12/2008 10:07:58 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1]   ASP.NET | WCF | AJAX  |  Trackback
Copyright © 2010 Kevin D. Wolf. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: