Exemplo n.º 1
0
        protected virtual void Application_Start()
        {
            try
            {
                Cms.OfficialEnvironment = false;
                Cms.OnInit += CmsEventRegister.Init;
                Cms.Init(BootFlag.Normal, null);

                //注册路由;
                RouteCollection routes = RouteTable.Routes;
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
                //在加载cms后避免覆盖 /cms.do
                Routes.RegisterCmsMajorRoutes(routes);
                // 加载插件
                WebCtx.Current.Plugin.Connect();
                //注册自定义路由
                RegisterRoutes(routes);
                //注册CMS路由
                Routes.RegisterCmsRoutes(routes, null);
                //RouteDebug.RouteDebugger.RewriteRoutesForTesting(routes);

                //加载自定义插件
                //Cms.Plugins.Extends.LoadFromAssembly(typeof(sp.datapicker.CollectionExtend).Assembly);

                //注册定时任务
                CmsTask.Init();
            }
            catch (NotImplementedException exc)
            {
                if (exc.InnerException != null)
                {
                    // exc = exc.InnerException;
                }
                try
                {
                    HttpResponse rsp = HttpContext.Current.Response;
                    rsp.Write(@"<html><head></head>
                        <body style=""text-align:center""><h1 style="""">" + exc.Message
                              + "</h1><hr /><span>jr.Cms v" + Cms.Version
                              + "</span>\r\n<span style=\"display:none\">"
                              + exc.StackTrace + "</span>"
                              + "</body></html>");
                    rsp.End();
                    Server.ClearError();
                }
                catch (Exception ex)
                {
                    throw exc;
                }
                finally
                {
                    HttpRuntime.UnloadAppDomain();
                }
                return;
            }
        }