Exemple #1
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(config => {
         WebApiConfig.Register(config);
         ODataConfig.Register(config);
     });
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors(police =>
            {
                police.AllowAnyOrigin();
                police.AllowAnyMethod();
                police.AllowAnyHeader();
            });
            app.UseAuthentication();
            app.UseMvcWithDefaultRoute();
            app.UseMvc(b =>
            {
                b.Select().Expand().Filter().OrderBy().MaxTop(100).Count();
                IList <IODataRoutingConvention> conventions = ODataRoutingConventions.CreateDefault();
                conventions.Insert(0, new MatchRoutingConvention());
                b.MapODataServiceRoute("odata", "odata", ODataConfig.GetEdmModel(), new DefaultODataPathHandler(), conventions);

                //b.MapODataServiceRoute("odata", "odata", ODataConfig.GetEdmModel());

                b.EnableDependencyInjection();
                b.MapRoute(
                    name: "default",
                    template: "api/{controller}/{action}/{id?}");
            });
            AutoMapperConfig.MapperConfig();
        }
Exemple #3
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     //  GlobalConfiguration.Configure(WebApiConfig.Register);
     GlobalConfiguration.Configure(config =>
     {
         ODataConfig.Register(config); //this has to be before WebApi
         WebApiConfig.Register(config);
     });
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Exemple #4
0
        public static void Register(HttpConfiguration config)
        {
            config.Filters.Add(new AuthorizeAttribute());
            config.Filters.Add(new DSWExceptionFilterAttribute());

            // Web API configuration and services
            config.MapHttpAttributeRoutes(new DSWWebApiRouteProvider());
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
            config.EnableCors();

            ODataConfig.Register(config);
            config.EnableDependencyInjection();
            config.EnsureInitialized();
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            UnityConfig.RegisterComponents();
            GlobalConfiguration.Configure(config =>
            {
                WebApiConfig.Register(config);
                ODataConfig.Register(config); //this has to be before WebApi
            });
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            log4net.Config.XmlConfigurator.Configure();
        }
        public static void StartWebApi(IAppBuilder app)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <ShowcaseDbContext, Configuration>());
            AutoMapperConfig.RegisterMappings(Assembly.Load(Constants.DataTransferModelsAssembly));

            var httpConfig = new HttpConfiguration();

            ODataConfig.Register(httpConfig);
            WebApiConfig.Register(httpConfig);

            httpConfig.EnsureInitialized();

            app
            .UseNinjectMiddleware(NinjectConfig.CreateKernel)
            .UseNinjectWebApi(httpConfig);
        }
Exemple #7
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     else
     {
         app.UseHsts();
     }
     app.UseMvc(
         rbuilder =>
     {
         rbuilder.Select().Expand().Filter().OrderBy().MaxTop(50).Count();
         rbuilder.MapODataServiceRoute("api/odata", "api/odata", ODataConfig.GetEdmModel());
     });
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthorization();

            // The following lines enable OData and its batching capabilities for HTTP routing.
            app.UseODataBatching();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.Select().Expand().Filter().OrderBy().MaxTop(10).Count();
                endpoints.MapODataRoute("odata", "odata", ODataConfig.GetEdmModel(), new DefaultODataBatchHandler());
            });
        }
Exemple #9
0
        /// <summary>
        /// Configures the specified application.
        /// </summary>
        /// <param name="app">The application.</param>
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();


            config.MapHttpAttributeRoutes();//for some reason, this must happen after Cors

            ODataConfig.Configuration(app, config);

            config.EnableDependencyInjection();

            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            //make sure no funny one tries XML instead of JSON
            config.Formatters.Remove(config.Formatters.XmlFormatter);
            //  config.Services.Replace(typeof(IHostBufferPolicySelector), new NoBufferPolicySelector());
            app.UseWebApi(config);

            config.EnsureInitialized();
        }
Exemple #10
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ConfitecContext context)
 {
     context.Database.Migrate();
     context.Database.EnsureCreated();
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
         app.UseSwagger();
         app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Confitec v1"));
     }
     app.UseCors("CorsOptions");
     app.UseHttpsRedirection();
     app.UseRouting();
     app.UseAuthorization();
     app.UseEndpoints(endpoints =>
     {
         endpoints.MapControllers();
         ODataConfig.UseODataCustom(endpoints);
     });
 }
Exemple #11
0
        protected void Application_Start(object sender, EventArgs e)
        {
            AreaRegistration.RegisterAllAreas();

            GlobalConfiguration.Configure(config =>
            {
                config.MapHttpAttributeRoutes();
                config.MapODataServiceRoute("odata", "odata", ODataConfig.GetModel(Assembly.GetExecutingAssembly()));
            });
            RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            RouteTable.Routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new
            {
                controller = "Home",
                action     = "Index",
                id         = UrlParameter.Optional
            }
                );
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseAuthentication();

            app.UseCors("AllowAll");

            app.UseAuthentication();

            app.UseMvc(routebuilder =>
            {
                //Enabling OData routing.
                routebuilder.MapODataServiceRoute("ODataRoutes", "odata", ODataConfig.GetBuilder().GetEdmModel());
            });

            app.UseMvc();
        }
Exemple #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseStaticFiles();
            app.UseSpaStaticFiles();
            app.UseCors(builder => builder.AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowAnyOrigin());

            app.UseSignalR(routes =>
            {
                routes.MapHub <TaskHub>("/taskHub");
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");

                routes.SetTimeZoneInfo(TimeZoneInfo.Utc);
                routes.MapODataServiceRoute("ODataRoute", "api", builder => builder
                                            .AddService(Microsoft.OData.ServiceLifetime.Singleton, sp => ODataConfig.BuildEdmModel(app.ApplicationServices))
                                            .AddService <IEnumerable <IODataRoutingConvention> >(Microsoft.OData.ServiceLifetime.Singleton, sp => ODataRoutingConventions.CreateDefaultWithAttributeRouting("ODataRoute", routes))
                                            .AddService <ODataUriResolver>(Microsoft.OData.ServiceLifetime.Singleton, sp => new StringAsEnumResolver {
                    EnableCaseInsensitive = true
                }));
            });

            app.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501

                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });


            AutoMapperConfig.RegisterMappings();
            EnsureDbCreated(app);
        }