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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:15:08+00:00 2026-06-12T23:15:08+00:00

I started a Visual Studio WCF Rest Service Application project where I want to

  • 0

I started a Visual Studio WCF Rest Service Application project where I want to have a service that returns a Json formatted message with a serialized object and I want SOME fields of the object not being serialized. I must say that my knowledge of WCF is very very basic and that I used the Rest Service Application project from Visual Studio because it’s a simple way to implement what I need fast.

Let’s say this is the object I have:

public class BaseMessage
{
    public string errorCode { get; set; }
    public string errorMessage { get; set; }
}

And this is my code

    [WebGet(UriTemplate = "/v1/test", 
    ResponseFormat = WebMessageFormat.Json),OperationContract]

    public BaseMessage Test()
    {
        return (new BaseMessage { errorCode = "000", errorMessage = "test" });
    }

I’ve read everywhere that what I need to do is to assign the [ScriptIgnore] attribute to the properties I don’t want to have serialized. But if I do, it doesn’t work. I get them serialized anyway.

The only way I have achieved what I want to do is declaring the object I want to return in this way:

[Serializable]
public class BaseMessage
{
    public string errorCode;
    [NonSerialized]
    public string errorMessage;
}

In this way I get the class serialized as I want. But it bugs me a lot as I might not be doing this thing right. Am I doing this right?

  • 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-12T23:15:09+00:00Added an answer on June 12, 2026 at 11:15 pm

    I think you should be using [DataContract] attribute for your data objects and [DataMember] for your object members

    like here http://msdn.microsoft.com/en-us/library/ms733127.aspx

    When you want to ignore an item; you mark it as [IgnoreDataMember] attribute

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

Sidebar

Related Questions

In a Visual Studio WCF Service Application project, on the properties->web page, if I
In my Visual Studio 2010 Solution with a WCF Service Project, I have my
Started using Visual Studio 2012 RC since yesterday, We have one WCF solution. Whenever
I've got a Visual Studio project that recently started throwing a ConfigurationErrorsException, and I
i have just started using visual studio 2008.I am working on c#. I want
Recently we started working with Database project in Visual Studio 2010. I have added
I have a WCF-Service, written in Visual Basic using Visual Studio 2010. I would
I have started writing a Macro in Visual Studio 2005 like this: Public Sub
I just started working on my first Visual Studio project, and I imported all
started a visual studio 2010 database project . however i am only able to

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.