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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:19:08+00:00 2026-05-29T09:19:08+00:00

I think something must not be correct with the serialization. My class is: [DataContract]

  • 0

I think something must not be correct with the serialization. My class is:

[DataContract]
public class User
{
    [DataMember]
    public int id { get; set; }
    [DataMember]
    public string user_id { get; set; }
    ...

    public User() { }

    public User(int id, string user_id, ...)
    {
        this.id = id;
        this.user_id = user_id;
        ...
    }
}

[DataContract]
public class UserCollection
{
    [DataMember]
    public List<User> users { get; set; }

    [DataMember]
    public int count { get; set; }

    [DataMember]
    public int page { get; set; }

    public UserCollection() { }

    public UserCollection(List<User> users, int count, int page)
    {
        this.users = users;
        this.count = count;
        this.page = page;
    }
}

The API call:

    [WebGet(UriTemplate = "?promotion_id={promotion_id}&page={page}&format={format}")]
    public UserCollection GetAllUsers(string promotion_id, string page, string format)
    {
        if (string.Equals("json", format, StringComparison.OrdinalIgnoreCase))
            WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Json;

        UserFactory factory = new UserFactory();
        return factory.GetUsersByPromotionID(int.Parse(promotion_id), (int.Parse(page) - 1) * 50, 50);
    }

The generated source:

<UserCollection xmlns="http://schemas.datacontract.org/2004/07/API.Library.Resources" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><count>0</count><page>0</page><users/></UserCollection>

It doesn’t display the xml on the page because it says the response type is text/html. Any ideas?

  • 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-29T09:19:08+00:00Added an answer on May 29, 2026 at 9:19 am

    What kind of client are you using to invoke the web service?

    You could try

    WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think there must be something subtle going on here that I don't know
I'm trying to find a way to to do something that I think must
I'm think something like Facebook apps here. User generated pieces of code that people
I'm trying to get this simple PowerShell script working, but I think something is
I think I'm missing something very obvious and its making my brain hurt. class
I think my problem is something simple, but I'm not seeing it. I'm new
I think I encountered something extraordinary strange in VS 2008. All the array values
I keep getting a exc bad access error and I think it has something
How would I do this? I think this has something to do with editing
This is something that I think would be very useful. Basically, I'd like there

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.