protected override void OnApplicationStarted() { AreaRegistration.RegisterAllAreas(); MVCControlsToolkit.Core.Extensions.Register(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Database.SetInitializer <RemontContext>(new InitDb()); using (RemontContext context = new RemontContext()) { context.Database.Initialize(true); } AuthConfig.RegisterAuth(); var stringProvider = new ResourceStringProvider(Resources.Resource.ResourceManager); ModelMetadataProviders.Current = new LocalizedModelMetadataProvider(stringProvider); ModelValidatorProviders.Providers.Clear(); ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider()); }
protected void Application_Start() { AutoMapperConfig.Configure(); //註冊AutoMapper AreaRegistration.RegisterAllAreas(); //decimal 顯示 ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder()); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //可崁在iframe裡 AntiForgeryConfig.SuppressXFrameOptionsHeader = true; //多國語言Language ResourceStringProvider rp = new ResourceStringProvider(Resources.ResourceManager); ModelMetadataProviders.Current = new LocalizedModelMetadataProvider(rp); //DI AutofacConfig.Register(); //json GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); }
public static void RegisterValidators() { var stringProvider = new ResourceStringProvider(Resources.LocalizedStrings.ResourceManager); ModelMetadataProviders.Current = new LocalizedModelMetadataProvider(stringProvider); ModelValidatorProviders.Providers.Clear(); ValidationMessageProviders.Clear(); ValidationMessageProviders.Add(new MvcDataSource()); ValidationMessageProviders.Add(new DataAnnotationDefaultStrings()); ValidationMessageProviders.Add(new GriffinStringsProvider(stringProvider)); var validatorProvider = new LocalizedModelValidatorProvider(); ModelValidatorProviders.Providers.Add(validatorProvider); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var stringProvider = new ResourceStringProvider(Resources.Resources.ResourceManager); System.Web.Mvc.ModelMetadataProviders.Current = new LocalizedModelMetadataProvider(stringProvider); ValidationMessageProviders.Clear(); ValidationMessageProviders.Add(new GriffinStringsProvider(stringProvider)); // the rest ValidationMessageProviders.Add(new MvcDataSource()); //mvc attributes ValidationMessageProviders.Add(new DataAnnotationDefaultStrings()); //data annotation attributes System.Web.Mvc.ModelValidatorProviders.Providers.Clear(); System.Web.Mvc.ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider()); DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; }