-
Notifications
You must be signed in to change notification settings - Fork 2
/
Global.asax.cs
51 lines (43 loc) · 1.72 KB
/
Global.asax.cs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using XgPush.SDK.Server;
namespace Sample.XgPush.SDK.Server
{
public class WebApiApplication : HttpApplication
{
private HttpClient GlobalHttpClient { get; set; }
protected void Application_Start()
{
GlobalHttpClient = new HttpClient();
XingePushClient.InitHttpClientCompatDefaultMagic();
XgPushConfig.Register(GlobalHttpClient);
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
var removeList = new List<MediaTypeFormatter>();
foreach (var formatter in GlobalConfiguration.Configuration.Formatters)
if (!(formatter is JsonMediaTypeFormatter))
removeList.Add(formatter);
foreach (var formatter in removeList) GlobalConfiguration.Configuration.Formatters.Remove(formatter);
MvcHandler.DisableMvcResponseHeader = true;
}
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
//HttpContext.Current.Response.Headers.Remove("Server");
HttpContext.Current.Response.Headers["Server"] = "Apache-Coyote/1.1";
}
private void Application_End(object sender, EventArgs e)
{
GlobalHttpClient?.Dispose();
}
}
}