Automatic Format Selection in WCF RESTful service

By | February 17, 2014

In .NET framework 4.0, Automatic Format Selection feature is introduced by AutomaticFormatSelectionEnabled property of WebHttpBehavior class. The purpose is to dynamically find out and return the response in appropriate format for a service operation.MCSD Exam: 70-487
If the value of this property is set to “true” means using Automatic Format Selection, the response format of the operation is determined by the following factors in the same ordered way:

  1. Accept header of Request Message
  2. Content-Type of the HTTP request Message
  3. ResponseFormat parameter of service operation.
  4. WebHttpBehavior’s default format settings

WCF RESTful Service
By default, AutomaticFormatSelectionEnabled property of WebHttpBehavior class is set to false. So, in my previous article on Step by step creating a WCF RESTful Service, we explicitly defined format selection of ResponseFormat parameter in Web operation as follows:

    public interface IProductRESTService
        [WebInvoke(Method = “GET”,
                                 ResponseFormat = WebMessageFormat.Xml,
                                 BodyStyle = WebMessageBodyStyle.Bare,
                                 UriTemplate = “GetProductList/”)]
        List GetProductList();

But when Automatic Format Selection feature is enabled, Accept header of request message takes the highest precedence. First of all, Windows Communication Foundation infrastructure looks for Accept header of Request message. If found an appropriate format, response will be returned in the same format. However, if not the value of Accept header is found suitable, then WCF will look for the next factor i.e. Content Type of Request Message.

In one of my WCF service tutorial, I have explained how to consume WCF RESTful service using jQuery? So, if you wanted to see that how to set media-type of Accept header or Content-Type of request message, you can find complete code in that WCF RESTful Service Example. For your understanding, following is the sample jQuery Ajax call for my WCF HTTP Service.

                 type: “GET”,
                 url: “http://localhost/XXXXXXX/XXX”,
                 dataType: “json”,
                 contentType: “json”,
                 success: function (data) {
//Success code…                     
                 error: function (xhr) {

In above jQuery code snippet, dataType represents the expected response format from server that becomes the value of Accept header in Request Message, while contentType is Content Type of the same.

So, in order, if no appropriate Content Type is specified, ResponseFormat parameter in WebInvokeAttribute/WebGetAttribute of service operation will be considered, already explained above.
Lastly, DefaultOutgoingResponseFormat property of WebHttpBehavior class will be used to determine the output format of WCF RESTful service response, if nothing found in service operation attribute.

Now, how to enable this Automatic Format Selection feature for a WCF RESTful service? It can be done programmatically as well as through configuration. Configuration settings for enabling this feature is simple and straight forward using:

  • WebHttpBehavior
  • WebHttpEndpoint

Using WebHttpBehavior:-

            <service name=”MyRESTService.ProductRESTService” behaviorConfiguration=”serviceBehavior”>
                <endpoint address=””
                               contract=”MyRESTService.IProductRESTService” behaviorConfiguration=”web”>
                <behavior name=”serviceBehavior”>
                    <serviceMetadata httpGetEnabled=”true”/>
                    <serviceDebug includeExceptionDetailInFaults=”false”/>
                <behavior name=”web”>
                    <webHttp automaticFormatSelectionEnabled=”true” />
        <serviceHostingEnvironment multipleSiteBindingsEnabled=”true” />

Using WebHttpEndpoint:-

                    <standardEndpoint name=”web”
 automaticFormatSelectionEnabled=”true”  />

Hopefully, this WCF tutorial has simplified the concept of Automatic Format Selection for Windows Communication Foundation RESTful service.

Recents WCF Jobs in USA

.Net web developer
Details: ASP.NET, MVC, WebAPI, WCF, Entity Framework. It’s very urgent requirement from client ,we have totally 5 openings ,I can give immediate interviews....  More
8 days ago

Baltimore, MD 15-November-2017

.Net Developer
Source: Indeed
Details: *Job Summary* *Job Title: .Net Developer - with Support and Maintenance experience* *Job Location: Rockville, MD* *Duration: Full Time ( Long Term) - Its a...  More
23 days ago

Rockville, MD 31-October-2017

.Net Developer // Plano, TX // Full-Time
Source: Indeed
Details: *Job Summary* *Job Title: .Net Developer* *Location: Plano, TX* *Duration: Full-Time* *Job Description: * * 6-9 Yrs years of relevant IT experience (SDLC-...  More
20 days ago

Plano, TX 03-November-2017

Sr. .Net Developer
Source: Zyston LLC
Details: .NET Software Developer We’re currently looking for a .NET Software Developer to join the team in Dallas, Texas.This is a highly visible team within a large...  More
21 days ago

Atlanta, GA 30328 02-November-2017

.Net Developer
Source: Indeed
Details: * MVC .Net * Kendo UI, * HTML5, CSS3, Bootstrap, * Knockout JS, JQuery * MVC Web API, WCF, SignalR Location: Snoqualmie, WA Job Type: Contract Job Type:...  More
15 days ago

Seattle, WA 08-November-2017

Dot Net Developers (5)
Source: Alt Shift USA
Details: A leading insurance company is looking for 5 full Stack .NET Developers required to design and develop their product. LOCAL CANDIDATES ONLY Candidate...  More
10 days ago

Chicago, IL 13-November-2017

.Net Developer
Source: Indeed
Details: *Monthly Salary: $4,000.00 - $5,719.00* *Job Posting Number: 1091* *Opening Date: 05/31/2017* *Closing Date: Open Until Closed* *Number of Openings: 1* ...  More
29 days ago

Austin, TX 78701 25-October-2017

Jr .Net Developer Looking independent consultants
Source: Indeed
Details: Experience in .NET web services, WCF, WPF and applications·. Looking for .Net Developer Independent consultant only....  More
21 days ago

Boston, MA 02-November-2017

Sr .NET Developer
Source: Indeed
Details: Value Momentum provides Software and Services to Insurance, Healthcare & Financial Services firms. Our Customers like working with us because we deliver value...  More
28 days ago

Pittsburgh, PA 26-October-2017

Sr. .NET Developer
Source: Indeed
Details: A solid understanding of developing RESTful Web APIs, Web Services, Web API WCF. Develop and test new application features....  More
30+ days ago

Charlotte, NC 12-October-2017

Jr .Net web services Developer
Source: Indeed
Details: C.Develop, implement, and support ASMX and WCF services. Jr .Net web services Developer....  More
23 days ago

New Haven, CT 31-October-2017

Dot Net Developer
Source: Indeed
Details: Experience with WCF, REST or SOAP based services and SOA. Software Engineer Engineer position provides technical leadership in areas of .NET web and database...  More
23 days ago

Houston, TX 31-October-2017

.Net Developer-Baltimore, MD
Source: Indeed
Details: C#,.NET,Winforms, WebForms, MVC/Web API, SSIS, WCF Services, AJAX/JSON, jQuery/jQueryUI, AngularJS. 3 to 7 years of experience, bachelors in computer science or...  More
30+ days ago

Baltimore, MD 31-July-2017

Mid Level Net Developer
Source: Indeed
Details: Zane Networks, LLC, a health IT company subcontracted under FEi for a software development project led by FEi. FEi is a leading IT company specializing in...  More
30+ days ago

Columbia, MD 14-September-2017

.NET Web Developer
Source: MIS Choice
Details: Knowledge of Web Services (RESTful, WCF). .NET Web Developer for Aviation Industry Software Leader....  More
30+ days ago

Mount Prospect, IL 60056 11-August-2017

.Net Developer
Source: Indeed
Details: Experience with WCF Services. As a Developer you will be involved in all phases of the Software Development Life Cycle (SDLC), and resolving issues related to...  More
2 days ago

Houston, TX 21-November-2017

.NET Developer
Source: Indeed
Details: *Job Summary* *.NET Developer* *Cambridge, MA* Indev has an immediate need for an innovative Web Developer with expertise in .NET technologies. The...  More
5 days ago

Cambridge, MA 18-November-2017

.Net Developer
Source: Indeed
Details: JQuery, AngularJS, Bootstrap, nhibernate or other ORM, XML, AWS, WCF, and Web Service development. The candidate will provide development and IT support for a...  More
9 days ago

Fairfax, VA 14-November-2017

.Net Developer
Source: Indeed
Details: *NOTE: * H1B,H4- EAD,UC,GC Visas Only On W2 No C2C. *Job Title* : .Net Developer *Location* : De Pere, WI *Duration* : Long Term *Mandatory Skills* : C#,...  More
10 days ago

De Pere, WI 13-November-2017

.Net Developer
Source: Indeed
Details: * At least 1 year of experince in Office 365 Development.• At least 2+ Years’ experience in Visual Studio Tools for Office(VSTO)• Atleast 6 years of...  More
13 days ago

Tampa, FL 10-November-2017

.NET Developer
Source: Indeed
Details: Good understanding of web services, SOAP, WCF, REST. Alpha Solutions is looking to hire a highly motivated .NET Developer, who wants to work with cutting-edge...  More
16 days ago

Dallas-Fort Worth, TX 07-November-2017

.Net Developer
Source: Indeed
Details: 5+ years with .NET Framework including 3.5, C#, the ASP.Net MVC framework, WCF Web Services, Relational Databases especially SQL 2008....  More
23 days ago

Atlanta, GA 31-October-2017

.Net Developer
Source: Indeed
Details: Broad experience with .NET Framework 3.5 or above including WPF, WCF, & WF. Hope you are doing great!!!...  More
30+ days ago

Pleasanton, CA 28-September-2017

.NET Software Developer – (Mid Level)
Source: Indeed
Details: *.NET Software Developer – (Mid Level)* At AINS we develop a family of COTS products for advanced dynamic case management. Our eCase case management...  More
14 days ago

Gaithersburg, MD 09-November-2017

Sr.Full Stack .Net Developer
Source: Indeed
Details: WCF. Experience with Web API and REST, WCF, LINQ, and MVC preferred (2+ year). Sr....  More
27 days ago

Dallas, TX 27-October-2017
Category: C# RESTful API WCF RESTful Service Tags: ,


Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at,, and

  • anish mounish

    This comment has been removed by a blog administrator.