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

  • Home
  • SEARCH
  • 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 4622784
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:53:33+00:00 2026-05-22T02:53:33+00:00

I’m using a .net script service which is called from client-side script, and it

  • 0

I’m using a .net script service which is called from client-side script, and it works very nicely.

only problem is- it generates a ‘__type’ attribute for each of the returned objects, which I don’t want or need.
I’ve seen a few posts about this over the web, and as far as I could tell, there are only ‘workarounds’ for this:

  • some people suggested hiding the parameter-less c’tor of the return type as ‘internal protected’,

  • others suggested not using the [ScriptMethod] tag, and instead JSONfy the result manually and return a string.

I’m wondering whether there is another, better, solution for this. and by the way- what is this attribute used for, anyway?
I’m enclosing the service method and the generated JSON.

method:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public IEnumerable<EmployeePO> GetEmployeesForDepartment(int DepartmentId)
{

        return new AdministrationController().GetEmployeesForDepartment(DepartmentId);

}

JSON returned:

{"d":[{"__type":"Application.Controllers.PresentationObjects.EmployeePO","Positions":[{"__type":"Application.Controllers.PresentationObjects.PositionPO","Id":4,"Name":"Employee: 1test Position 1","IsPriority":false,"WarningThreshold":50,"CriticalThreshold":60,"CurrentWaitingTime":-1,"Passengers":[],"Qualifications":[...
  • 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-22T02:53:33+00:00Added an answer on May 22, 2026 at 2:53 am

    OK so I ended up taking the advice from Jhon Morrison, posted in the question @Kid linked to-
    I defined all the parameter-less constructors on my returned classes as protected internal and that really did the trick.
    In cases where I actually needed to create empty objects I created a Factory method, like so:

    public class MyClass
        {
            public int Id { get; set; }
            /*...*/
    
            public MyClass(int id):
            {
                Id = id;
            }
    
    
            public static MyClass CreateNewZonePO()
            {
                return new MyClass();
            }
    
            //parameterless c'tor for serialization's sake
            //it's protected internal in order to avoid the "__type" attribute when returned from a web service. see http://stackoverflow.com/questions/4958443/net-script-web-services-type-attribute
            protected internal MyClass()
            {
    
            }
        }
    

    @Kid’s answer also worked, but it looked cleaner to me this way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.