This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
/
Global.asax.cs
77 lines (72 loc) · 3.52 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
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.ExpressApp.Security;
using DevExpress.ExpressApp.Web;
namespace WebSolution.Web {
public class Global : System.Web.HttpApplication {
public Global() {
InitializeComponent();
}
protected void Application_Start(Object sender, EventArgs e) {
#if EASYTEST
DevExpress.ExpressApp.Web.TestScripts.TestScriptsManager.EasyTestEnabled = true;
ConfirmationsHelper.IsConfirmationsEnabled = false;
#endif
}
protected void Session_Start(Object sender, EventArgs e) {
WebApplication.SetInstance(Session, new WebSolutionAspNetApplication());
#if EASYTEST
if(ConfigurationManager.ConnectionStrings["EasyTestConnectionString"] != null) {
WebApplication.Instance.ConnectionString = ConfigurationManager.ConnectionStrings["EasyTestConnectionString"].ConnectionString;
}
#endif
DevExpress.Persistent.Base.Tracing.NeedContextInformation += Tracing_NeedContextInformation;
WebApplication.Instance.ConnectionString = Demo.CodeCentralExampleInMemoryDataStoreProvider.ConnectionString;
if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null) {
WebApplication.Instance.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}
DevExpress.ExpressApp.Xpo.InMemoryDataStoreProvider.Register();
WebApplication.Instance.ConnectionString = DevExpress.ExpressApp.Xpo.InMemoryDataStoreProvider.ConnectionString;
WebApplication.Instance.Setup();
WebApplication.Instance.Start();
}
private static void Tracing_NeedContextInformation(object sender, DevExpress.Persistent.Base.NeedContextInformationEventArgs e) {
string user = string.IsNullOrEmpty(SecuritySystem.CurrentUserName) ? "Unknown" : SecuritySystem.CurrentUserName;
string host = string.IsNullOrEmpty(HttpContext.Current.Request.UserHostAddress) ? "Unknown" : HttpContext.Current.Request.UserHostAddress;
e.ContextInformation = string.Format("User = {0}, Host = {1}", user, host);
}
protected void Application_BeginRequest(Object sender, EventArgs e) {
string filePath = HttpContext.Current.Request.PhysicalPath;
if (!string.IsNullOrEmpty(filePath)
&& (filePath.IndexOf("Images") >= 0) && !System.IO.File.Exists(filePath)) {
HttpContext.Current.Response.End();
}
}
protected void Application_EndRequest(Object sender, EventArgs e) {
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
}
protected void Application_Error(Object sender, EventArgs e) {
ErrorHandling.Instance.ProcessApplicationError();
}
protected void Session_End(Object sender, EventArgs e) {
WebApplication.LogOff(Session);
WebApplication.DisposeInstance(Session);
}
protected void Application_End(Object sender, EventArgs e) {
}
#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
}
}