using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Web.Http;

namespace TFC
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}/{pass}",
                defaults: new { id = RouteParameter.Optional , pass = RouteParameter.Optional}
            );
            var jsonformatter = config.Formatters.Where(t => t.GetType() == typeof(JsonMediaTypeFormatter)).FirstOrDefault();
            config.Formatters.Remove(jsonformatter );
            config.Formatters.Insert(0, jsonformatter); 
            config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
        }
    }
}
