i am a programming student, working with a asp.net mvc 4 web app, i am testing a simple web app that uses the http://openweathermap.org/api so when i click a link, it executes the Action Result on the home controller, the code to get the data from the api is in this action result and it fetches the api json data and stores it in a viewbag.message that is then passed back to the view. I have that much working in so far as i can get the json result and see it on the view. I am not sure how to proceed & the pages i have looked up seem to be centered around ajax jquery
My question is about the serializing/displaying the json result without adding any plugins or anything just yet, i would like to format / serialise it so it looks better maybe fit it into a table or something, but without getting into ajax & jquery just yet as i haven't learned that part yet.
I have removed the api key from the code.
public ActionResult getWeather()
{
var uri = "http://api.openweathermap.org/data/2.5/forecast?id=7778677&APPID=123456789";
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
var resultContent = client.DownloadString(uri);
ViewBag.Message = resultContent;
return View();
}
And here is the result view:
screenshot of result view showing the json data from the api
I hope i am explaining myself correctly, Thank You. M.