public static class WebApiConfig
{
public static void Register(System.Web.Http.HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}"
);
var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault
(t => t.MediaType == "application/xml");
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
}
}
Main with SelHost
class Program
{
public static void Main()
{
var config = new System.Web.Http.SelfHost.HttpSelfHostConfiguration("http://Localhost:8080");
WebApiConfig.Register(config);
using (var server = new System.Web.Http.SelfHost.HttpSelfHostServer(config))
{
server.OpenAsync().Wait();
Console.WriteLine("Press Enter to quit.");
Console.ReadLine();
}
}
}
Комментариев нет:
Отправить комментарий