当前位置: 首页>>代码示例>>C#>>正文


C# IApplicationBuilder类代码示例

本文整理汇总了C#中IApplicationBuilder的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder类的具体用法?C# IApplicationBuilder怎么用?C# IApplicationBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IApplicationBuilder类属于命名空间,在下文中一共展示了IApplicationBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
    
            var section = Configuration.GetSection("MongoDB");
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseIISPlatformHandler();
            app.UseCors("AllowAll");
            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                  name:"api",
                  template: "api/{controller}/{id?}"  
                );
             });
        }
开发者ID:DarriusWrightGD,项目名称:ASP.NET-Core-Angular2,代码行数:28,代码来源:Startup.cs

示例2: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.Run(context =>
     {
         return context.Response.WriteAsync("Hello PriyaLaksmi");
     });
 }
开发者ID:Rajakani,项目名称:CoreApp,代码行数:7,代码来源:Startup.cs

示例3: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            app.UseIISPlatformHandler();

            app.UseDefaultFiles();
            app.UseStaticFiles();
        }
开发者ID:crabulik,项目名称:CrabulikAngular2Ex,代码行数:8,代码来源:Startup.cs

示例4: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseIISPlatformHandler();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.Use(async (context, next) =>
            {
                context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
                context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
                context.Response.Headers.Add("Access-Control-Allow-Headers", new[] { "Content-Type, x-xsrf-token" });

                if (context.Request.Method == "OPTIONS")
                {
                    context.Response.StatusCode = 200;
                }
                else
                {
                    await next();
                }
            });

            app.UseMvc();

            SampleData.Initialize(app.ApplicationServices);
        }
开发者ID:gobetti,项目名称:ContactsBackEnd,代码行数:34,代码来源:Startup.cs

示例5: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseMiddleware(typeof(MyMiddleware));
     
     app.Run(async context =>
         await context.Response.WriteAsync("---------- Done\r\n"));
 }
开发者ID:leloulight,项目名称:Entropy,代码行数:7,代码来源:Startup.cs

示例6: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseRequestLocalization();

            // Add MVC to the request pipeline
            app.UseMvcWithDefaultRoute();
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:Startup.cs

示例7: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseIISPlatformHandler();
     
     app.Run(async context =>
     {
         var singleton1 = context.RequestServices.GetService<ISingleton>();
         var singleton2 = context.RequestServices.GetService<ISingleton>();
         var scoped1 = context.RequestServices.GetService<IScoped>();
         var scoped2 = context.RequestServices.GetService<IScoped>();
         var transient1 = context.RequestServices.GetService<ITransient>();
         var transient2 = context.RequestServices.GetService<ITransient>();
         var instance1 = context.RequestServices.GetService<IInstance>();
         var instance2 = context.RequestServices.GetService<IInstance>();
         
         await context.Response.WriteAsync(
             "<table>" +
             $"<tr><td>Singleton 1 and Singleton 2 are the same instance:</td><td> {object.ReferenceEquals(singleton1, singleton2)}</td></tr>" +
             $"<tr><td>Instance 1 and Instance 2 are the same instance:</td><td> {object.ReferenceEquals(instance1, instance2)}</td></tr>" +
             $"<tr><td>Scoped 1 and Scoped 2 are the same instance:</td><td> {object.ReferenceEquals(scoped1, scoped2)}</td></tr>" +
             $"<tr><td>Transient 1 and Transient 2 are the same instance:</td><td> {object.ReferenceEquals(transient1, transient2)}</td></tr>" +
             "</table><br><br><table>" +
             $"<tr><td>Singleton Id:</td><td> {singleton1.Id}</td></tr>" +
             $"<tr><td>Instance Id:</td><td> {instance1.Id}</td></tr>" +
             $"<tr><td>_instanceId:</td><td> {InstanceId}</td></tr>" +
             $"<tr><td>Scoped Id:</td><td> {scoped1.Id}</td></tr>" +
             $"<tr><td>Transient 1 Id:</td><td> {transient1.Id}</td></tr>" +
             $"<tr><td>Transient 2 Id:</td><td> {transient2.Id}</td></tr>" +
             "</table>");
     });
 }
开发者ID:jeffogata,项目名称:aspnet-di-03-vs,代码行数:31,代码来源:Startup.cs

示例8: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
            ILoggerFactory loggerFactory)
        {
            // The hosting environment can be found in a project's properties -> DEBUG or in launchSettings.json.
            if (_hostingEnvironment.IsDevelopment())
            {
                // The exception page is only shown if the app is in development mode.
                app.UseDeveloperExceptionPage();
            }

            // This middleware makes sure our app is correctly invoked by IIS.
            app.UseIISPlatformHandler();

            // Add the MVC middleware service above first. Then use said middleware in this method.
            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute(
            //        name: "default",
            //        template: "{controller}/{action}/{id}",
            //        defaults: new { controller = "Home", action = "Index" }
            //    );
            //});

            app.UseMvcWithDefaultRoute();

            // Always remember to add the static files middleware or the images from JavaScript or CSS 
            // won't be served.
            app.UseStaticFiles();

            // Whenever HTTP status codes like 404 arise, the below middleware will display them on the page.
            app.UseStatusCodePages();
        }
开发者ID:jimxshaw,项目名称:samples-csharp,代码行数:33,代码来源:Startup.cs

示例9: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.Run(context =>
             {
             return context.Response.WriteAsync("Hello from ASP.NET Core!");
             });
 }
开发者ID:jeffwmair,项目名称:samplecode,代码行数:7,代码来源:Startup.cs

示例10: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, BeaconsContextSeedData seeder)
        {

            app.UseStaticFiles();
            app.UseDeveloperExceptionPage();


            Mapper.Initialize(config =>
            {
                config.CreateMap<Beacon, BeaconViewModel>().ReverseMap();
                config.CreateMap<Log, LogViewModel>().ReverseMap();
            });

            app.UseIISPlatformHandler();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action ="Index"}
                    );
            });

            seeder.EnsureSeedData();
        }
开发者ID:ganeshnj,项目名称:BeaconApplication,代码行数:27,代码来源:Startup.cs

示例11: Configure

        public void Configure(IApplicationBuilder app)
        {
            _validatorProvider.ServiceProvider = app.ApplicationServices;

            // Add MVC to the request pipeline.
            app.UseMvcWithDefaultRoute();
        }
开发者ID:Rinsen,项目名称:MvcModelBindingAndFromServicesIssue,代码行数:7,代码来源:Startup.cs

示例12: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseCultureReplacer();

            app.UseErrorReporter();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "isbn10",
                    template: "book/{action}/{isbnNumber:IsbnDigitScheme10(true)}",
                    defaults: new { controller = "InlineConstraints_Isbn10" });

                routes.MapRoute("StoreId",
                        "store/{action}/{id:guid?}",
                        defaults: new { controller = "InlineConstraints_Store" });

                routes.MapRoute("StoreLocation",
                        "store/{action}/{location:minlength(3):maxlength(10)}",
                        defaults: new { controller = "InlineConstraints_Store" },
                        constraints: new { location = new AlphaRouteConstraint() });

                // Used by tests for the 'exists' constraint.
                routes.MapRoute("areaExists-area", "area-exists/{area:exists}/{controller=Home}/{action=Index}");
                routes.MapRoute("areaExists", "area-exists/{controller=Home}/{action=Index}");
                routes.MapRoute("areaWithoutExists-area", "area-withoutexists/{area}/{controller=Home}/{action=Index}");
                routes.MapRoute("areaWithoutExists", "area-withoutexists/{controller=Home}/{action=Index}");
            });
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:29,代码来源:Startup.cs

示例13: Configure

 // Configure is called after ConfigureServices is called.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     // Add MVC to the request pipeline.
     app.UseMvc();
     // Add the following route for porting Web API 2 controllers.
     // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
 }
开发者ID:jamisliao,项目名称:aws-sdk-net-samples,代码行数:8,代码来源:Startup.cs

示例14: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                //app.UseErrorPage(ErrorPageOptions.ShowAll);
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // sends the request to the following path or controller action.
                //app.UseErrorHandler("/Home/Error");
            }

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
            });

            app.UseMvc();
        }
开发者ID:Richiban,项目名称:Marketplace2.0,代码行数:28,代码来源:Startup.cs

示例15: Configure

 public static void Configure(IApplicationBuilder app)
 {
     app.UseMvc(routes => {
         routes.MapRoute("Dashboard", "app/{*catchall}", new { controller = "dashboard", action = "index" });
         routes.MapRoute("Default", "{controller=home}/{action=index}/{id?}");
     });
 }
开发者ID:miffy081409,项目名称:IAT,代码行数:7,代码来源:RouteConfig.cs


注:本文中的IApplicationBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。