-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobal.asax.cs
117 lines (100 loc) · 4.7 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
using System.Web;
using System.Security.Principal;
using System.Data;
using DFISYS.Ultility;
using DFISYS.User.Security;
using System.IO;
using System.IO.Compression;
using System.Configuration;
namespace DFISYS {
/// <summary>
/// Summary description for Global.
/// </summary>
public class Global : System.Web.HttpApplication {
public Global() {
InitializeComponent();
}
/// <summary>
/// Thuc hien Install mot so file cau hinh neu he thong khong co.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Application_Start(Object sender, EventArgs e) {
//Indexer indexer = new Indexer();
}
protected void Application_BeginRequest(Object sender, EventArgs e) {
////###### begin use compress ###################
//HttpApplication app = (HttpApplication)sender;
//string acceptEncoding = app.Request.Headers["Accept-Encoding"];
//Stream prevUncompressedStream = app.Response.Filter;
//if (acceptEncoding == null || acceptEncoding.Length == 0)
// return;
//acceptEncoding = acceptEncoding.ToLower();
//string _physicalPath = app.Request.Url.LocalPath;
//if (_physicalPath.Contains(".aspx") || _physicalPath.Contains(".aspx"))
//{
// if (acceptEncoding.Contains("gzip"))
// {
// // gzip
// app.Response.Filter = new GZipStream(prevUncompressedStream, CompressionMode.Compress);
// app.Response.AppendHeader("Content-Encoding", "gzip");
// }
// else if (acceptEncoding.Contains("deflate"))
// {
// // defalte
// app.Response.Filter = new DeflateStream(prevUncompressedStream, CompressionMode.Compress);
// app.Response.AppendHeader("Content-Encoding", "deflate");
// }
// //app.Response.Cache.SetExpires(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, (DateTime.Now.Minute + 10), 30));
//}
////########### end use compress ########################
}
protected void Application_Error(Object sender, EventArgs e) {
Exception ex = Server.GetLastError().GetBaseException();
object WriteErrorToFile = ConfigurationManager.AppSettings["WriteErrorToFile"];
if (WriteErrorToFile != null && WriteErrorToFile.ToString().ToUpper() == "TRUE") {
CreateLogFiles Err = new CreateLogFiles();
Err.ErrorLog(Server.MapPath("/ErrorLog"), Request.Url.ToString() + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace);
}
}
protected void Session_Start(Object sender, EventArgs e) {
}
protected void Application_EndRequest(Object sender, EventArgs e) {
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
if (Request.IsAuthenticated) {
string[] roles = null;
MainSecurity objscu = new MainSecurity();
roles = objscu.GetRoleSymbol(HttpContext.Current.User.Identity.Name, DFISYS.API.Config.CurrentChannel);
//ChannelUsers objUser = new ChannelUsers();
//string[] roles = objUser.getRoles(HttpContext.Current.User.Identity.Name);//UserManagement.GetRoles(HttpContext.Current.User.Identity.Name);
HttpContext.Current.User = new GenericPrincipal(HttpContext.Current.User.Identity, roles);
}
}
protected void Session_End(Object sender, EventArgs e) {
}
protected void Application_End(Object sender, EventArgs e) {
}
public override string GetVaryByCustomString(HttpContext context, string custom) {
if (custom.ToLower() == "cachingmultiversion") {
HttpCookie cookie = context.Request.Cookies["CachingMultiVersion"];
if (cookie != null) return cookie.Value;
}
return base.GetVaryByCustomString(context, custom);
}
public static string CachingMultiVersion {
set {
System.Web.HttpContext.Current.Response.Cookies["CachingMultiVersion"].Value = value;
}
}
#region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
}
#endregion
}
}