Ejemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            // Register the default hubs route: ~/signalr
            RouteTable.Routes.MapHubs();

            //wepb api route
            GlobalConfiguration.Configure(WebApiConfig.Register);
            //UnityConfig.RegisterComponents();

            //chỉ sử dụng 1 view razor thôi
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());//add razor view engine


            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AutoMapperConfiguration.Configure();

            //disabled

            //Enable or Disable Client Side Validation at Application Level
            HtmlHelper.ClientValidationEnabled      = true;
            HtmlHelper.UnobtrusiveJavaScriptEnabled = true;
            //
            ModelBinders.Binders.Add(typeof(decimal?), new DecimalModelBinder());
            ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
            ModelBinders.Binders.Add(typeof(DateTime), new MyDateTimeModelBinder());
            ModelBinders.Binders.Add(typeof(int?), new IntegerModelBinder());
            ModelBinders.Binders.Add(typeof(int), new IntegerModelBinder());


            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
        }
 public static void Run()
 {
     SetAutofacContainer();
     //Configure AutoMapper
     AutoMapperConfiguration.Configure();
 }