Esempio n. 1
0
        protected void Application_Start()
        {
            CfTrace.InitializeTraceSource(new Instrumentation.CfTraceSource("Cf.Web"));

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RouteRegistrar.RegisterRoutes(RouteTable.Routes);

            //-- Setup caching depending on if we're running in the cloud or not
            if (!RoleEnvironment.IsAvailable)
            {
                CfCacheIndex.Initialize(); CfPerfCache.Initialize();
            }
            else
            {
                CfCacheIndex.Initialize(new Level2MemcachedCacheIndex()); CfPerfCache.Initialize(new Level2MemcachedPerfCache());
            }

            Microsoft.IdentityModel.Web.FederatedAuthentication.ServiceConfigurationCreated += new EventHandler
                                                                                               <Microsoft.IdentityModel.Web.Configuration.ServiceConfigurationCreatedEventArgs>(RsaServerfarmSessionCookieTransform.OnServiceConfigurationCreated);
        }
Esempio n. 2
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            if (WebConfigSettings.EnableVirtualPathProviders)
            {
                try
                {
                    log.Info(Resource.ApplicationStartEventMessage);
                    RegisterVirtualPathProvider();
                }
                catch (MissingMethodException ex)
                {                   // this is broken on mono, not implemented 2006-02-04
                    log.Error("Application_Start Could not register VirtualPathProvider, missing method in Mono", ex);
                }
                catch (SecurityException se)
                {
                    // must not be running in full trust
                    log.Error("Application_Start Could not register VirtualPathProvider, this error is expected when running in Medium trust or lower", se);
                }
                catch (UnauthorizedAccessException ae)
                {
                    // must not be running in full trust
                    log.Error("Application_Start Could not register VirtualPathProvider, this error is expected when running in Medium trust or lower", ae);
                }
            }


#if !NET35 && !NET40
            if (WebConfigSettings.EnableRouting)
            {
                AreaRegistration.RegisterAllAreas();
                GlobalConfiguration.Configure(WebApiConfig.Register);
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteRegistrar.RegisterRoutes(RouteTable.Routes);
            }

            BundleConfig.RegisterBundles(BundleTable.Bundles);
#endif



            StartOrResumeTasks();
            PurgeOldLogEvents();

//#if !NET35
//            appDomainMonitoringEnabled = WebConfigSettings.AppDomainMonitoringEnabled;
//            firstChanceExceptionMonitoringEnabled = WebConfigSettings.FirstChanceExceptionMonitoringEnabled;
//            try
//            {
//                SetupMonitoring();
//            }
//            catch (MethodAccessException)
//            {
//                log.Info("Failed to setup application monitoring, not allowed under medium trust.");
//                appDomainMonitoringEnabled = false;
//                firstChanceExceptionMonitoringEnabled = false;
//            }

            //#endif

#if !NET35 && !NET40
            if (WebConfigSettings.UnobtrusiveValidationMode == "WebForms")
            {
                if (WebConfigSettings.ForceEmptyJQueryScriptReference)
                {
                    // since we already have jquery loaded
                    // we need to fool scriptmanager by loading a fake version here
                    // to avoid an error http://stackoverflow.com/questions/12065228/asp-net-4-5-web-forms-unobtrusive-validation-jquery-issue
                    ScriptResourceDefinition jQuery = new ScriptResourceDefinition();
                    jQuery.Path = "~/ClientScript/empty.js";
                    ScriptManager.ScriptResourceMapping.AddDefinition("jquery", jQuery);
                }
            }
#endif
        }
Esempio n. 3
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            try
            {
                ServicePointManager.SecurityProtocol |= ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12;
            }
            catch (System.NotSupportedException)
            {
                log.Error("Application_Start could not set the chosen security protocol.");
            }

            if (WebConfigSettings.EnableVirtualPathProviders)
            {
                try
                {
                    log.Info(Resource.ApplicationStartEventMessage);
                    RegisterVirtualPathProvider();
                }
                catch (MissingMethodException ex)
                {                   // this is broken on mono, not implemented 2006-02-04
                    log.Error("Application_Start Could not register VirtualPathProvider, missing method in Mono", ex);
                }
                catch (SecurityException se)
                {
                    // must not be running in full trust
                    log.Error("Application_Start Could not register VirtualPathProvider, this error is expected when running in Medium trust or lower", se);
                }
                catch (UnauthorizedAccessException ae)
                {
                    // must not be running in full trust
                    log.Error("Application_Start Could not register VirtualPathProvider, this error is expected when running in Medium trust or lower", ae);
                }
            }


            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ViewEngines.Engines.Clear();

            mojoViewEngine engine = new mojoViewEngine();

            //engine.AddViewLocationFormat("~/Data/Sites/{2}/skins/Views/{1}/{0}.cshtml");
            //engine.AddViewLocationFormat("~/Data/Sites/{2}/skins/Views/{1}/{0}.vbhtml");

            // Add a shared location too, as the lines above are controller specific
            //engine.AddPartialViewLocationFormat("~/Data/Sites/{1}/skins/Views/{0}.cshtml");
            //engine.AddPartialViewLocationFormat("~/Data/Sites/{1}/skins/Views/{0}.vbhtml");

            ViewEngines.Engines.Add(engine);

            //var razorEngine = ViewEngines.Engines.OfType<RazorViewEngine>().FirstOrDefault();
            //razorEngine.ViewLocationFormats =
            //    razorEngine.ViewLocationFormats.Concat(new string[] {
            //        "~/MyVeryOwn/{1}/{0}.cshtml",
            //        "~/MyVeryOwn/{0}.cshtml"
            //        // add other folders here (if any)
            //    }).ToArray();

            AreaRegistration.RegisterAllAreas();
            RouteRegistrar.RegisterRoutes(RouteTable.Routes);

            CreateSystemInfoCache();

            StartOrResumeTasks();
            PurgeOldLogEvents();

//#if !NET35
//            appDomainMonitoringEnabled = WebConfigSettings.AppDomainMonitoringEnabled;
//            firstChanceExceptionMonitoringEnabled = WebConfigSettings.FirstChanceExceptionMonitoringEnabled;
//            try
//            {
//                SetupMonitoring();
//            }
//            catch (MethodAccessException)
//            {
//                log.Info("Failed to setup application monitoring, not allowed under medium trust.");
//                appDomainMonitoringEnabled = false;
//                firstChanceExceptionMonitoringEnabled = false;
//            }

            //#endif

//#if!NET35 && !NET40

            if (WebConfigSettings.UnobtrusiveValidationMode == "WebForms")
            {
                if (WebConfigSettings.ForceEmptyJQueryScriptReference)
                {
                    // since we already have jquery loaded
                    // we need to fool scriptmanager by loading a fake version here
                    // to avoid an error http://stackoverflow.com/questions/12065228/asp-net-4-5-web-forms-unobtrusive-validation-jquery-issue
                    ScriptResourceDefinition jQuery = new ScriptResourceDefinition();
                    jQuery.Path = "~/ClientScript/empty.js";
                    ScriptManager.ScriptResourceMapping.AddDefinition("jquery", jQuery);
                }
            }
//#endif
        }