-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (27 loc) · 977 Bytes
/
Program.cs
File metadata and controls
32 lines (27 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Web.Http;
using System.Web.Http.SelfHost;
using WebApi.OutputCache.Core.Cache;
namespace WebApi.OutputCache.V2.Demo
{
class Program
{
static void Main(string[] args)
{
const string hostUrl = "http://localhost:999";
var config = new HttpSelfHostConfiguration(hostUrl);
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
var server = new HttpSelfHostServer(config);
config.CacheOutputConfiguration().RegisterCacheOutputProvider(() => new MemoryCacheDefault());
server.OpenAsync().Wait();
Console.WriteLine($"WebAPI Hosted and listening on: {hostUrl}");
Console.ReadKey();
server.CloseAsync().Wait();
}
}
}