I'm new on ASP.Net Web API and want to develop a sample to get date time. I developed two applications.In the first one i Have my API and run it throw Visual Studio and another one is a console application to test the first.
On my API I have:
public class DateTimeController : ApiController
{
   public DateTime Get()
    {
        return DateTime.Now;
    }
}
and on my Console application I have this,but i do not know it's correct or not because it doesn't work:
  static void Main(string[] args)
    {
        string baseAddress = "http://localhost:13204/api/DateTime/get";
        using (HttpClient httpClient = new HttpClient())
        {
            Task<String> response =
             httpClient.GetStringAsync(baseAddress);
        }
        Console.ReadLine();
    }
Quick watch on response:
        response.Status=WaitingForActivation
        response.id=4
        response.AsyncState=null
WebApiConfig.cs
 public static void Register(HttpConfiguration config)
    {
        // Web API configuration and services
        // Web API routes
        config.MapHttpAttributeRoutes();
        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    }
RouteConfig.cs
public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "DateTime", action = "Get", id = UrlParameter.Optional }
        );
    }
}
 
     
    