WCF Web Service – Enabling JSON – Solution 1

Hello!

The main reason I am posting this really simple post only because, even though it is simple, it wasted a lot of time for me. There are several ways to enable JSON request and response for WCF web service. But the easiest I think is this one

1. Just select AJAX Enabled Web Service from the add new item window if you are using Visual Studio ( I used VS2010). By default this will talk to the clients with JSON. There you go.

2. But, If you really want to know whats the difference between AJAX Enabled Web Service and WCF Web Service, open the new added AJAX Enabled Web Service. Just over the class declaration you will notice a line that says –

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

The second line is the main reason. It enabled the service to allow JSON type messaging from a client.

Now, I know this is not the only solution, you can also enable JSON response/request in a WCF Service, but I have not really tested that case, will post as soon I am done…

If this is found helpful, don’t forget to leave a comment, thanks.

Advertisements

5 thoughts on “WCF Web Service – Enabling JSON – Solution 1

  1. Richard

    It’s hard to find your articles in google. I found it on 19 spot, you should build quality backlinks , it will
    help you to rank to google top 10. I know how to help you, just type in google – k2 seo tricks

    Like

  2. Quentin

    I read a lot of interesting posts here. Probably you spend
    a lot of time writing, i know how to save you a
    lot of work, there is an online tool that creates
    unique, google friendly articles in minutes, just type in google – laranitas free content
    source

    Like

  3. Gloria

    You post interesting posts here. Your website deserves much bigger audience.
    It can go viral if you give it initial boost, i know useful tool that
    can help you, just search in google: svetsern traffic tips

    Like

  4. Pingback: Weight Loss - Weight Loss Advice

Leave a Reply to Quentin Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.