forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorRedirectModule.cs
More file actions
41 lines (35 loc) · 954 Bytes
/
ErrorRedirectModule.cs
File metadata and controls
41 lines (35 loc) · 954 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
33
34
35
36
37
38
39
40
41
using System;
using System.Web;
using BaiRong.Core;
namespace SiteServer.API
{
public class ErrorRedirectModule : IHttpModule
{
public string ModuleName => "ErrorRedirectModule";
public void Init(HttpApplication app)
{
app.Error += Application_Error;
}
private static void Application_Error(object sender, EventArgs e)
{
try
{
var ex = HttpContext.Current.Server.GetLastError();
if (ex.InnerException != null)
{
ex = ex.InnerException;
}
LogUtils.AddErrorLog(ex, "Application Error");
HttpContext.Current.Server.ClearError();
PageUtils.RedirectToErrorPage(ex.Message);
}
catch
{
// ignored
}
}
public void Dispose()
{
}
}
}