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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:07:51+00:00 2026-06-18T16:07:51+00:00

I have made a WCF service in .NET 4 platform, that when I hit

  • 0

I have made a WCF service in .NET 4 platform, that when I hit it with a jquery ajax POST it returns JSON.
The issue that I have is that I would prefer if the json response of the POST is not wrapped in the name of the Method with the Result suffix.

In detail:

public interface IService
{
    [OperationContract]
    [WebInvoke(Method = "POST",
 ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
    Person GetInfo(string id);
}

[AspNetCompatibilityRequirements(RequirementsMode
    = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service: Iservice
{
    public Person GetInfo(string id)
    {
           ...
           return new Person();
    }
}

public class Person
{
  public string FirstName;
  public string LastName;

  public Person(){
   FirstName = "Jon";
   LastName = "Doe";
  }
}

web.config
<system.serviceModel>
   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
   <behaviors>
     <serviceBehaviors>
       <behavior name="ServiceBehavior">
         <serviceMetadata httpGetEnabled="true"/>
         <serviceDebug includeExceptionDetailInFaults="true"/>
       </behavior>
     </serviceBehaviors>
     <endpointBehaviors>
       <behavior name="EndpBehavior">
         <webHttp/>
       </behavior>
     </endpointBehaviors>
   </behaviors>
   <services>
     <service behaviorConfiguration="ServiceBehavior" name="Service">
       <endpoint address="" binding="webHttpBinding"
           contract="IService" behaviorConfiguration="EndpBehavior"/>
     </service>
   </services>
 </system.serviceModel>

jquery:

var myparameters = JSON.stringify({ id: $('#id').val()});
            $.ajax({
                type: "POST",
                url: "/Service.svc/GetInfo",
                data:myparameters,
                contentType: "application/json",
                dataType: "json",
                success: function (response) {
                      ...
                    }
                }
            });

With the BodyStyle = WebMessageBodyStyle.Wrapped the response a get in my javascript code is:

{"GetInfoResult" : {"FirstName":"Jon", "LastName":"Doe"}}

But when I change it to WebMessageBodyStyle.Bare and everything else remains the same, a 500 internal server error occurs.

Is it possible to return Bare json in my POST response without the Method+Result wrapper? If yes what am I doing wrong?

Thanks in advance

  • 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-18T16:07:52+00:00Added an answer on June 18, 2026 at 4:07 pm

    I think that WebMessageBodyStyle.Bare expects also a “bare” request, and you are sending an object from your javascript code, something like this : {id:'value'} that will be translated as :

    public class DTObject{
      public string Id { get; set; }
    }
    

    And your operation method expects only a string as parameter.

    Try to make only your response “bare” like this WebMessageBodyStyle.WrappedRequest.

    [Edit]
    http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webmessagebodystyle.aspx

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

Sidebar

Related Questions

I have a WCF Service hosted in IIS/ASP.NET that accepts HTTP Post ( not
We have a simple ASP.Net WCF Ajax enabled web service which is called via
Hey I have made an WCF service and would like to be able to
I am using the .NET 4 framework and have made a WCF Workflow Service
I have a call to a SOAP WCF Service that returns a lot of
I have a WCF web service that uses ASP.NET session state. WCF sets a
I have a simple WCF service which has a method that returns a complex
I have made a REST Web service, that works with Visual Studios WCF Test
I have made a jQuery toggle for a menu that I had in mind.
I have a WCF web service that exposes several business methods. I also have

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.