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

  • Home
  • SEARCH
  • 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 6040165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:28:28+00:00 2026-05-23T06:28:28+00:00

i know im not the first with this problem, but i cant seem to

  • 0

i know im not the first with this problem, but i cant seem to find a working solution

when using a webservice set to return json, .net still wraps it in an XML wrapper.

i searched and tried many things

  1. i tried adding various httphandler settings to my web.config, as suggested in certain posts, but these had no effect. also i don’t think its necessary as im working on a brand new win7/iis7.5/.net4 box. i read that since .net 3.5 there shouldn’t be any problem. but there is!
  2. i tried with and without the responseformat.json decoration. my webservice returns valid json ( i can parse it with parsejson, after extracting the string)
  3. i tried explicitly setting the contenttype and datatype. this causes an error complaining that the response was invalid json. which is right!

what is happening is very confusing, in IE , at least on my devbox, the response returns as an xml document where i can just use msg.text and easily get the json string, but in production i tested in FF and it returns as a document, with no “text” property.

heres my javascript/jquery

$.ajax({
error: function (xhr, ajaxOptions, thrownError) {
    alert(xhr.status+'-'+xhr.statusText);
    alert(thrownError);
    },
    url: '<%=ResolveUrl("~/WebService.asmx")%>' + "/JackJill",
    contentType: "application/json",
    success: function (msg) {
        alert(msg.d); 
    }
});

so: how can i simply ask .net to return a valid regular json string, instead of wrapping it. i believe that will solve all the problems. it will also make my service more accessible to the world at large, so they don’t have to do any special parsing.

thank you very much for any advice or pointers

sincerely

EDIT:
heres a sample webservice that i just tested:

<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> <WebMethod()> Public Function JackJill() As String
    Return "[{""Name"":""Jack""},{""Name"":""Jill""}]"
End Function

then when i put this in the browser

http://localhost:81/webservice.asmx/JackJill

i get

<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">
[{"Name":"Jack"},{"Name":"Jill"}]
</string> 

why all this xml stuff here?

  • 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-23T06:28:29+00:00Added an answer on May 23, 2026 at 6:28 am

    I realise this question is old but just in case someone else is looking at this answer in the future ….

    I have found (according to this http://encosia.com/asmx-and-json-common-mistakes-and-misconceptions/ and this http://weblogs.asp.net/scottgu/archive/2007/04/04/json-hijacking-and-how-asp-net-ajax-1-0-mitigates-these-attacks.aspx) that if you wish to consume JSON from an .ASMX it’s necessary to :

    • set the content type to ‘application/json’ and
    • set the method to ‘POST’

    Up above Yisman says he doesn’t want to restrict his service to POST requests but (according to those two references) it does seem that if you wish to use .ASMX and receive JSON that’s what you’re going to have to do.

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

Sidebar

Related Questions

this is my first question here :) I know that I should not check
First, I know about Clog , and I do not want to implement this
I know I can read off /proc/[id]/maps but I'm not sure if the first
First of all, I know that UDP is not a reliable protocol but I
I know this question has been asked several times, but I can't quite seem
I've searched and searched, but I can't seem to find a fix for this
I've looked around here but can't seem to find an answer to my problem.
I know this is a task that can't be unique, but I can't seem
I've got a really weird problem and I can't seem to find a solution
first time posting here, but god know's I use this site to search for

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.