Forums - C# Corner

Forum guidelines
Mark Lynn

Mark Lynn

  • 1.7k
  • 2
  • 573

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)


Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now