I am trying to learn how to create an API with ASP.NET MVC (I'm using vNext). To do this, I'm just trying to return the current date. At this time, I have the following:
using System;
using Microsoft.AspNet.Mvc;
[Route("api/test")]
public class TestController : Controller
{
[HttpGet("date")]
public string Date()
{
return Json(new { result = 1, currentDate = DateTime.UtcNow });
}
}
I execute this from fiddler via the composer tab. When I do that, http://localhost:5001/api/test. I press Execute. The result is a status code of 200. However, there is no JSON. Instead, I get the "Welcome Your ASP.NET vNext application has successfully started" page.
What am I doing wrong?