I would like to create a web application that returns data in the form of XML or JSON, how do I go about doing this?
The model:
namespace ReturningJSONandXML.Models
{
public class SomeImportantInformation
{
public int ID { get; set; }
public string Information { get; set; }
}
}
The controller:
namespace ReturningJSONandXML.Controllers
{
public class GetInfoController : Controller
{
// GET: /<controller>/
public List<SomeImportantInformation> Get()
{
List<SomeImportantInformation> ImportantInfo = new List<SomeImportantInformation>();
ImportantInfo.Add(new SomeImportantInformation { ID = 0, Information = "Awesome info" });
ImportantInfo.Add(new SomeImportantInformation { ID = 1, Information = "Some other interesting info" });
return ImportantInfo;
}
}
}
I would like to return an XML and JSON file...
What are the best practice's I should be using here?