| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Web;
- using Abp.Castle.Logging.Log4Net;
- using Abp.Dependency;
- using Abp.Timing;
- using Abp.Web;
- using Abp.Web.Localization;
- using Castle.Facilities.Logging;
- using WePlatform.Configuration;
- using IwbZero.ToolCommon.LogHelpers;
- using WePlatform.CommonManager.AppGuids;
- namespace WePlatform
- {
- public class MvcApplication : AbpWebApplication<WePlatformWebModule>
- {
- protected override void Application_Start(object sender, EventArgs e)
- {
- AbpBootstrapper.IocManager.IocContainer.AddFacility<LoggingFacility>(
- f => f.UseAbpLog4Net().WithConfig(Server.MapPath("log4net.config"))
- );
- this.LogInfo("Application -- System Starting!");
- base.Application_Start(sender, e);
- //加载RECORDID文件
- RecordIdManager.LoadDictionary();
- this.LogInfo("Application -- System Started!");
- }
- protected override void Application_End(object sender, EventArgs e)
- {
- // 在应用程序关闭时运行的代码
- this.LogInfo("Application -- System End!");
- }
- protected override void Application_Error(object sender, EventArgs e)
- {
- // 在出现未处理的错误时运行的代码
- //获取到HttpUnhandledException异常,这个异常包含一个实际出现的异常
- Exception ex = Server.GetLastError();
- //实际发生的异常
- Exception innerException = ex.InnerException;
- if (innerException != null) ex = innerException;
- this.LogFatal(ex);
- }
- protected override void Application_BeginRequest(object sender, EventArgs e)
- {
- var langCookie = Request.Cookies[IwbConsts.LocalizationCookieName];
- if (langCookie == null)
- {
- Context.Response.SetCookie(
- new HttpCookie(IwbConsts.LocalizationCookieName, "zh-Hans")
- {
- Expires = Clock.Now.AddYears(2),
- Path = Context.Request.ApplicationPath
- }
- );
- }
- base.Application_BeginRequest(sender, e);
- }
- protected override void Session_Start(object sender, EventArgs e)
- {
- // 在新会话启动时运行的代码
- this.LogInfo("Session_Start");
- }
- protected override void Session_End(object sender, EventArgs e)
- {
- // 在会话结束时运行的代码。
- // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 InProc 时,才会引发 Session_End 事件。
- // 如果会话模式设置为 StateServer
- // 或 SQLServer,则不会引发该事件。
- this.LogInfo("Session_End");
- }
- protected override void SetCurrentCulture()
- {
- AbpBootstrapper.IocManager.Using<ICurrentCultureSetter>(cultureSetter => cultureSetter.SetCurrentCulture(Context));
- }
- }
- }
|