コード例 #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var mapper = AutomapperConfiguration.Init();

            IoCBuilder.InitWeb(Assembly.GetExecutingAssembly(), mapper);
        }
コード例 #2
0
        /// <summary>
        /// Gets the configuration.
        /// </summary>
        /// <param name="configure">The configure.</param>
        private static void GetConfig(HttpConfiguration configure)
        {
            configure.EnableCors();
            configure.Formatters.Remove(configure.Formatters.XmlFormatter);
            //// Configure JSON output to how we want it
            var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;

            //// camelCase JSON properties
            json.SerializerSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
            json.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
            configure.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

            configure.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            GlobalConfiguration.Configuration.EnsureInitialized();
            IoCBuilder.InitWeb(Assembly.GetExecutingAssembly(), configure);
        }
コード例 #3
0
 protected void Application_Start(object sender, EventArgs e)
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     IoCBuilder.InitWeb(Assembly.GetExecutingAssembly(), GlobalConfiguration.Configuration);
 }