コード例 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, FooService fooService)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.Run(async(context) =>
            {
                var names             = fooService.GetNames();
                StringBuilder builder = new StringBuilder();
                foreach (var name in names)
                {
                    if (Configuration.GetValue <bool>("CapitalizedWords"))
                    {
                        builder.Append(name.ToUpper() + " ");
                    }
                    else
                    {
                        builder.Append(name + " ");
                    }

                    await context.Response.WriteAsync(builder.ToString());
                }
                ;
            });
            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute(
            //        name: "default",
            //        template: "{controller=Home}/{action=Index}/{id?}");
            //});
        }