45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace WebApp1
|
|
{
|
|
public class Startup2
|
|
{
|
|
#region snippet1
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddMvc()
|
|
// Include the 2.1 behaviors
|
|
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
|
|
// Except for the following.
|
|
.AddMvcOptions(options =>
|
|
{
|
|
// Don't combine authorize filters (keep 2.0 behavior).
|
|
options.AllowCombiningAuthorizeFilters = false;
|
|
// All exceptions thrown by an IInputFormatter will be treated
|
|
// as model state errors (keep 2.0 behavior).
|
|
options.InputFormatterExceptionPolicy =
|
|
InputFormatterExceptionPolicy.AllExceptions;
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
|
{
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
app.Run(async (context) =>
|
|
{
|
|
await context.Response.WriteAsync("Hello World!");
|
|
});
|
|
}
|
|
}
|
|
}
|