This repository was archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGlobal.asax.cs
78 lines (74 loc) · 2.9 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
#region Copyright Syncfusion Inc. 2001-2022.
// Copyright Syncfusion Inc. 2001-2022. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Microsoft.AspNet.SignalR;
using MVCSampleBrowser.Error;
using System.Data.Common;
using System.IO;
using System.Text;
using Syncfusion.Licensing;
namespace MVCSampleBrowser
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
RouteTable.Routes.MapHubs();
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
string License = File.ReadAllText(Server.MapPath("SyncfusionLicense.txt"), Encoding.UTF8);
SyncfusionLicenseProvider.RegisterLicense(License);
//AuthConfig.RegisterAuth();
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
}
protected void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
RouteData routeData = new RouteData();
routeData.Values.Add("ErrorMsg", exception.Message);
routeData.Values.Add("StackTrace", exception.StackTrace);
routeData.Values.Add("Controller", "ErrorHandler");
if (exception is DbException)
{
routeData.Values.Add("Action", "DatabaseError");
}
else if (exception is HttpException)
{
routeData.Values.Add("ExUrl", HttpContext.Current.Request.Url);
if ((exception as HttpException).GetHttpCode() == 404)
routeData.Values.Add("Action", "PageError");
else
routeData.Values.Add("Action", "CommonError");
}
else
routeData.Values.Add("Action", "CommonError");
Response.Clear();
Server.ClearError();
try
{
IController exceptionControl = new ErrorHandlerController();
exceptionControl.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
}
catch (Exception)
{
}
}
}
}