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


C# IBuilder.Run方法代码示例

本文整理汇总了C#中IBuilder.Run方法的典型用法代码示例。如果您正苦于以下问题:C# IBuilder.Run方法的具体用法?C# IBuilder.Run怎么用?C# IBuilder.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBuilder的用法示例。


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

示例1: Configure

        public void Configure(IBuilder app)
        {
            app.UseOwin(addToPiepline =>
            {
                addToPiepline(next =>
                {
                    return async env =>
                    {
                        var accept = env["websocket.Accept"] as WebSocketAccept;
                        if (accept == null)
                        {
                            // Not a websocket request
                            await next(env);
                        }
                        else
                        {
                            accept(null, WebSocketEcho);
                        }
                    };
                });
            });

            app.Run(async context =>
            {
                context.Response.ContentType = "text/plain";
                await context.Response.WriteAsync("Not a WebSocket");
            });
        }
开发者ID:kulmugdha,项目名称:Entropy,代码行数:28,代码来源:Startup.cs

示例2: ConfigurePK

 private void ConfigurePK(IBuilder builder)
 {
     builder.UseErrorPage();
     builder.Run(context =>
     {
         throw new Exception("Demonstration exception");
     });
 }
开发者ID:jizhonglee,项目名称:DiagnosticsPages,代码行数:8,代码来源:Startup.cs

示例3: Configure

 public void Configure(IBuilder app)
 {
     app.Run(async context =>
     {
         var payload = "Hello World";
         context.Response.ContentLength = payload.Length;
         await context.Response.WriteAsync(payload);
     });
 }
开发者ID:kjellski,项目名称:HelloWorldVNext,代码行数:9,代码来源:Startup.cs

示例4: Configure

 public void Configure(IBuilder app)
 {
     // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
     app.Run(async context =>
     {
         context.Response.ContentType = "text/plain";
         context.Response.ContentLength = "Hello Firefly!".Length;
         await context.Response.WriteAsync("Hello Firefly!");
     });
 }
开发者ID:FireflyServer,项目名称:firefly,代码行数:10,代码来源:Startup.cs

示例5: Configure

 public void Configure(IBuilder app)
 {
     var config = new Configuration();
     config.AddEnvironmentVariables();
     
     app.Run(async ctx => 
     {
         ctx.Response.ContentType = "text/plain";
         DumpConfig(ctx.Response, config);
     });
 }
开发者ID:boro2g,项目名称:AspNetVNextSamples,代码行数:11,代码来源:Startup.cs

示例6: Configure

        public void Configure(IBuilder app)
        {
            // Enable Browser Link support
            app.UseBrowserLink();

            // Setup configuration sources
            var configuration = new Configuration();

            //configuration.AddIniFile("config.ini");
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            //app.Run(async context =>
            //{
            //    await context.Response.WriteAsync(configuration.Get("Data:Configuration"));
            //});

            app.Run(async context =>
            {
                var asm = Assembly.Load(new AssemblyName("klr.host"));
                var assemblyVersion = asm.GetCustomAttribute<AssemblyInformationalVersionAttribute>();

                await context.Response.WriteAsync(assemblyVersion.InformationalVersion);
            });

            // Set up application services
            app.UseServices(services =>
            {
                // Add EF services to the services container
                services.AddEntityFramework().AddInMemoryStore();
                services.AddScoped<PersonContext>();

                // Add MVC services to the services container
                services.AddMvc();
            });

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

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default", 
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
开发者ID:julid29,项目名称:confsamples,代码行数:52,代码来源:Startup.cs

示例7: Configure

        public void Configure(IBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {

            });

            app.Run(async context =>
            {
                if (context.User == null || !context.User.Identity.IsAuthenticated)
                {
                    context.Response.SignIn(new ClaimsIdentity(new[] { new Claim("name", "bob") }, CookieAuthenticationDefaults.AuthenticationType));

                    context.Response.ContentType = "text/plain";
                    await context.Response.WriteAsync("Hello First timer");
                    return;
                }

                context.Response.ContentType = "text/plain";
                await context.Response.WriteAsync("Hello old timer");
            });
        }
开发者ID:kingdango,项目名称:Security,代码行数:22,代码来源:Startup.cs


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