本文整理汇总了C#中IApplicationBuilder.UseJson方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseJson方法的具体用法?C# IApplicationBuilder.UseJson怎么用?C# IApplicationBuilder.UseJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseJson方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public void Configure(IApplicationBuilder app)
{
app.UsePlainText();
app.UseJson();
app.UseMvc();
}
示例2: Configure
public void Configure(IApplicationBuilder app)
{
var kestrel = app.ServerFeatures[typeof(IKestrelServerInformation)] as IKestrelServerInformation;
if (kestrel != null)
{
// Using an I/O thread for every 2 logical CPUs appears to be a good ratio
kestrel.ThreadCount = Environment.ProcessorCount >> 1;
kestrel.NoDelay = true;
}
app.UseErrorHandler();
app.UsePlainText();
app.UseJson();
if (StartupOptions.EnableDbTests)
{
app.UseSingleQueryRaw(StartupOptions.ConnectionString);
app.UseSingleQueryEf();
var dbContext = (ApplicationDbContext)app.ApplicationServices.GetService(typeof(ApplicationDbContext));
var seeder = (ApplicationDbSeeder)app.ApplicationServices.GetService(typeof(ApplicationDbSeeder));
if (!seeder.Seed(dbContext))
{
Environment.Exit(1);
}
Console.WriteLine("Database tests enabled");
}
app.UseMvc();
app.Run(context => context.Response.WriteAsync("Try /plaintext instead"));
}
示例3: Configure
public void Configure(IApplicationBuilder app)
{
app.UseErrorHandler();
app.UsePlainText();
app.UseJson();
if (StartupOptions.EnableDbTests)
{
app.UseSingleQueryRaw(StartupOptions.ConnectionString);
app.UseSingleQueryDapper(StartupOptions.ConnectionString);
app.UseSingleQueryEf();
app.UseMultipleQueriesRaw(StartupOptions.ConnectionString);
app.UseMultipleQueriesDapper(StartupOptions.ConnectionString);
app.UseMultipleQueriesEf();
app.UseFortunesRaw(StartupOptions.ConnectionString);
app.UseFortunesDapper(StartupOptions.ConnectionString);
app.UseFortunesEf();
var dbContext = (ApplicationDbContext)app.ApplicationServices.GetService(typeof(ApplicationDbContext));
var seeder = (ApplicationDbSeeder)app.ApplicationServices.GetService(typeof(ApplicationDbSeeder));
if (!seeder.Seed(dbContext))
{
Environment.Exit(1);
}
Console.WriteLine("Database tests enabled");
}
app.UseMvc();
app.Run(context => context.Response.WriteAsync("Try /plaintext instead"));
}
示例4: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Configure the HTTP request pipeline.
//app.UseStaticFiles();
app.UseMvc();
app.UseJson();
app.UsePlainText();
// Add MVC to the request pipeline.
// Add the following route for porting Web API 2 controllers.
// routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
}
示例5: Configure
public void Configure(IApplicationBuilder app)
{
var kestrel = app.ServerFeatures[typeof(IKestrelServerInformation)] as IKestrelServerInformation;
if (kestrel != null)
{
// BUG: Multi-loop Kestrel doesn't work on Windows right now, see https://github.com/aspnet/KestrelHttpServer/issues/232
// kestrel.ThreadCount = 2;
}
app.UsePlainText();
app.UseJson();
app.UseMvc();
}
示例6: Configure
public void Configure(IApplicationBuilder app, ApplicationDbSeeder dbSeeder, ApplicationDbContext dbContext)
{
if (Scenarios.Plaintext)
{
app.UsePlainText();
}
if (Scenarios.Json)
{
app.UseJson();
}
// Single query endpoints
if (Scenarios.DbSingleQueryRaw)
{
app.UseSingleQueryRaw();
}
if (Scenarios.DbSingleQueryDapper)
{
app.UseSingleQueryDapper();
}
if (Scenarios.DbSingleQueryEf)
{
app.UseSingleQueryEf();
}
// Multiple query endpoints
if (Scenarios.DbMultiQueryRaw)
{
app.UseMultipleQueriesRaw();
}
if (Scenarios.DbMultiQueryDapper)
{
app.UseMultipleQueriesDapper();
}
if (Scenarios.DbMultiQueryEf)
{
app.UseMultipleQueriesEf();
}
// Multiple update endpoints
if (Scenarios.DbMultiUpdateRaw)
{
app.UseMultipleUpdatesRaw();
}
if (Scenarios.DbMultiUpdateDapper)
{
app.UseMultipleUpdatesDapper();
}
if (Scenarios.DbMultiUpdateEf)
{
app.UseMultipleUpdatesEf();
}
// Fortunes endpoints
if (Scenarios.DbFortunesRaw)
{
app.UseFortunesRaw();
}
if (Scenarios.DbFortunesDapper)
{
app.UseFortunesDapper();
}
if (Scenarios.DbFortunesEf)
{
app.UseFortunesEf();
}
if (Scenarios.Any("Db"))
{
dbContext.Database.EnsureCreated();
if (!dbSeeder.Seed())
{
Environment.Exit(1);
}
}
if (Scenarios.Any("Mvc"))
{
app.UseMvc();
}
if (Scenarios.StaticFiles)
{
app.UseStaticFiles();
}
app.RunDebugInfoPage();
}