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 7891741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:41:42+00:00 2026-06-03T06:41:42+00:00

I have stumbled up on some thing today. The below are my sample classes.

  • 0

I have stumbled up on some thing today. The below are my sample classes.

public class Employee
{
public string Name{get;set;}
Public Department Dept {get;set;}
public IList<Roles> Roles;
}

public Department{
public string Name{get;set;}
}

public Role {
public string Name{get;set;}
}


 sampleApiController : ApiContrller{
 public IEnumerable<string> Get(){
 return new List<string>{"Pavan", "Josyula"};
}
public Employee GetEmp(int id){

Employee e = new Employee();
e.Dept = "IT";
e.Name="Pav";
IList<Roles> r = new IListRoles();
r.Add(new Role{Name="Integrator"});
e.Roles = r;
return e;

  }
}

Now when I call this GetEmp Method from my broswer it is always giving me response in JSON format no matter what my content type in AcceptHeaders. But when I call my Get method, it returns collection of strings in XML format also it acts based on accept verb in request header. Can some body tell me the reason for this default JSON behaviour for custom types.

  • 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-06-03T06:41:43+00:00Added an answer on June 3, 2026 at 6:41 am

    This is because XmlSerializer can’t serialize IList<T>. Please read below answer for more details:

    • Differences in content negotiation between collections and single values in MVC 4
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I stumbled onto this problem today, let me explain the issue: I have this
I have stumbled upon the following F77 yacc grammar: http://yaxx.cvs.sourceforge.net/viewvc/yaxx/yaxx/fortran/fortran.y?revision=1.3&view=markup . How can I
I'm quite new to hibernate and have stumbled on this problem, which I can't
I am learning about LLDP protocol and have stumbled across terms chassis ID and
I have been playing about with canvas, but have stumbled across a problem. When
I've been practicing for an upcoming programming competition and I have stumbled across a
I'm mucking about with jQuery AJAX and have stumbled upon an oddity (or rather
I am going through Programming Ruby - a pragmatic programmers guide and have stumbled
I am looking for Java-based Less CSS compilers. On Github, I have stumbled across
I have recently stumbled upon a problem with selecting relationship details from a 1

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.