本文整理汇总了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");
});
}
示例2: ConfigurePK
private void ConfigurePK(IBuilder builder)
{
builder.UseErrorPage();
builder.Run(context =>
{
throw new Exception("Demonstration exception");
});
}
示例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);
});
}
示例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!");
});
}
示例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);
});
}
示例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?}");
});
}
示例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");
});
}