示例#1
0
        public void Application_Start(object sender, EventArgs e)
        {
            System.Web.Helpers.AntiForgeryConfig.UniqueClaimTypeIdentifier = System.Security.Claims.ClaimTypes.Name;
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new CustomViewEngine());
            XmlConfigurator.Configure();
            var config = GlobalConfiguration.Configuration;

            config.MapHttpAttributeRoutes();
            config.EnsureInitialized();
            LogManager.GetLogger(GetType()).Info("Application start!");
            var dbMigrator = new DatabaseMigrator();

            if (dbMigrator.ShouldRun)
            {
                if (!dbMigrator.CanConnectToDatabase())
                {
                    throw new Exception("Cannot connect to the database. Please check your connection string and ensure the database exists.");
                }
                if (!dbMigrator.Run())
                {
                    throw new Exception("Failed to Upgrade the Database using the pending Migrations. Please, see the Log file for further details.");
                }
            }
            new AccessLogManager().Run();
            RegisterRoutes(RouteTable.Routes);
            RuntimePredicateBuilder.RequiredAssembliesPaths = new List <string>()
            {
                Server.MapPath("bin\\DSS2_SynchromodalityCapacityOptimisation.Backend.dll"),
                Server.MapPath("bin\\DSS2_SynchromodalityCapacityOptimisation.Web.dll"),
                Server.MapPath("bin\\zAppDev.DotNet.Framework.dll")
            };
            WebFormResources.ClearResources = true;
            Utilities.InitXssEncoder();
        }