using System.Web.Http;
{
var config = new HttpSelfHostConfiguration("http://localhost:8080");
config.Routes.MapHttpRoute(
"API Default", "api/{controller}/{id}",
new { id = RouteParameter.Optional });
using (HttpSelfHostServer server = new HttpSelfHostServer(config))
{
server.OpenAsync().Wait();
}
}
else
{
string re = WebApiServer.HttpGet("http://localhost:8080/api/Products");
Console.WriteLine(re);
}
Console.WriteLine("Press Enter to quit.");
Console.ReadLine();
using System.Web.Http.SelfHost;
Console.WriteLine("输入1 启动服务,其他值查看http://localhost:8080/api/Products返回结果");
if (Console.ReadLine() == "1"){
var config = new HttpSelfHostConfiguration("http://localhost:8080");
config.Routes.MapHttpRoute(
"API Default", "api/{controller}/{id}",
new { id = RouteParameter.Optional });
using (HttpSelfHostServer server = new HttpSelfHostServer(config))
{
server.OpenAsync().Wait();
}
}
else
{
string re = WebApiServer.HttpGet("http://localhost:8080/api/Products");
Console.WriteLine(re);
}
Console.WriteLine("Press Enter to quit.");
Console.ReadLine();