Forums - C# Corner

Forum guidelines
Mark Lynn

Mark Lynn

  • 1.5k
  • 2
  • 469

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?
 

http://www.c-sharpcorner.com/UploadFile/8ef97c/web-service-in-Asp-Net-part-4/

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.
 
Thanks
 
 

Answers (1)