Forums - C# Corner

Forum guidelines
Mark Lynn

Mark Lynn

  • 1.5k
  • 2
  • 435

Returning JSON from C# Webservice WITHOUT the XML Tags

Mar 16 2016 1:06 PM
Using this article as a basis,  how does one omit the XML tags?

First off, the article was well done; short, concise, clear, and simple.
Regarding my question, I've seen it asked many places, but no one seems to really have the answer.  Though some are very impressive in their convolution. 
This bit of code gets me really close:
HttpContext Context = HttpContext.Current;

Context.Response.ContentType = "application/json";
Context.Response.Write(list);   // list here is a valid JSON object
Ideally, it seems I should be able to call the service via browser, and not get an error stating there was an XML parse record.   However, I DO get that error.

Answers (1)