Esempio n. 1
0
        protected virtual void Application_Start()
        {
            try
            {
                Cms.OnInit += CmsEventRegister.Init;
                Cms.Init();
            }
            catch (Exception exc)
            {
                //Server.ClearError();
                //if (HttpContext.Current.Response != null)
                //{
                //    HttpContext.Current.Response.Write("<html><head></head><body style=\"text-align:center\"><h1 style=\"\">" + exc.Message
                //        + "</h1><hr /><span>ops.cms v" + Cms.Version
                //        + "</span><span style=\"display:none\">" + exc.StackTrace + "</span>"
                //        + "</body></html>");
                //    HttpRuntime.UnloadAppDomain();
                //}
                //else
                //{
                //    throw new Exception(exc.Message);
                //}
                try
                {
                    if (HttpContext.Current.Response != null)
                    {
                        HttpContext.Current.Response.Write(
                            "<html><head></head><body style=\"text-align:center\"><h1 style=\"\">" + exc.Message
                            + "</h1><hr /><span>ops.cms v" + Cms.Version
                            + "</span><span style=\"display:none\">" + exc.StackTrace + "</span>"
                            + "</body></html>");
                        Server.ClearError();
                    }
                }
                catch
                {
                }
                finally
                {
                    HttpRuntime.UnloadAppDomain();
                }
                return;
            }

            //注册路由;
            RouteCollection routes = RouteTable.Routes;

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //注册自定义路由
            RegisterRoutes(routes);

            //注册CMS路由
            Routes.RegisterCmsRoutes(routes, null);
            //RouteDebug.RouteDebugger.RewriteRoutesForTesting(routes);

            //注册定时任务
            CmsTask.Init();
        }
Esempio n. 2
0
        protected virtual void Application_Start()
        {
            try
            {
                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 (Exception 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;
            }
        }