Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4554192
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:03:20+00:00 2026-05-21T17:03:20+00:00

I’m working with asmx webservices and serializing/deserializing a lot of data through them for

  • 0

I’m working with asmx webservices and serializing/deserializing a lot of data through them for a JSON admin panel I’m working on.

When information is loaded, i call a webservice that loads a User[] array into javascript. However, I have around 25 subclasses of User with their own unique properties that are actually getting loaded by this webservice call. It seems to work fine to load them this way, but saving has some issues.

The save method takes an array of User[] to save. On most of the subclasses, there is no __type hint in the javascript, and the deserialization fails. It seems to work fine on the classes that do have a __type property.

So my question is this. How can i force the __type to be included in the javascript objects that get serialized?

Here’s my C# call to load the objects (simplified a bit) just in case you need it:

[WebMethod(EnableSession = true)]
public User[] GetUsersInGroup(int UserGroupID)
{
    List<User> UsersInGroup = User.GetUsersInGroup(UserGroupID);
    return UsersInGroup.ToArray();
}

And here’s the Save Method:

[WebMethod(EnableSession = true)]
public void SaveUsers(User[] Users)
{
        foreach (User CurUser in Users)
        {
            CurUser.Save();
        }
}

And as requested, the Service Header:

  [ScriptService]
    public class FormFields : System.Web.Services.WebService
    {

And the JSON (simplified) – comment shows what isn’t there:

{
    "d": [
        {
            "__type": "Tools.User.AccountingUser",  /* This is missing */
            "UserID": 3934,
            "HasQBAccess": true 
        },
        {
            "__type": "Tools.User.PowerUser",
            "UserID": 3937,
            "AccessDB": true,
            "AccessFTP": true 
        } 
    ] 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:03:21+00:00Added an answer on May 21, 2026 at 5:03 pm

    In the interest of having some sort of answer that works, even if it isn’t a good one.

    So far, the best answer I can find is to add a really long ugly function definition to my webservice. I never have to call it, just letting it sit there makes C# recognize the types:

    [WebMethod(EnableSession = true)]
    public void ThisMethodSucks(AccountingUser u1, PowerUser u2, AdminUser u3, DatabaseUser u4, ADAdministratorUser u5, PSUser u6, NUTUser u7, TechUser u8, ...[all classes here])
    {
          //this method never needs to get called, just sits here.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.