을 사용하여 압축되었다 ... 그들은 기본적으로 활성화 gzip을하지했습니다
: ... 난 항상
WebApiConfig config file
에 .. 프로젝트에서 다음이
https://github.com/azzlack/Microsoft.AspNet.WebApi.MessageHandlers.Compression
같은 패키지를 사용을 활성화하기
.NET 코어 (2.0)를 사용하는 경우 더 간단합니다! 이 프레임 워크에 포함 ..cause .. 당신이 좋아하는 Configure method
에 있습니다 .. StartUp.cs file
에서 활성화 단지가 있습니다
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//LOGGER
loggerFactory.AddConsole(Configuration.GetSection("Logging")); //log levels set in your configuration
loggerFactory.AddDebug(); //does all log levels
//EXCEPTIONS
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler(errorApp =>
{
errorApp.Run(async context =>
{
context.Response.StatusCode = 500;
context.Response.ContentType = "text/plain";
var errorFeature = context.Features.Get<IExceptionHandlerFeature>();
if (errorFeature != null)
{
var logger = loggerFactory.CreateLogger("Global exception logger");
logger.LogError(500, errorFeature.Error, errorFeature.Error.Message);
}
await context.Response.WriteAsync("There was an error");
});
});
}
//APP CONFIGURATIONS
app.UseStaticFiles();
app.UseCors("AllowAllOrigins");
app.UseMvc();
app.UseSwagger();
app.UseResponseCompression(); // <<-- THIS ENABLE COMPRSSISON FOR YOUR FILES AND RESPONSE !!!!!!!!
//SWAGGER CONF
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
}
는 당신 도움이되기를 바랍니다!
안녕하세요. Asp.NET WEBPI 2를 사용하고 계십니까? –
@federicoscamuzzi 그렇습니다, 왜 내가 핸들러 대신 미들웨어를 사용하고 있는지. –
@federicoscamuzzi 죄송합니다 .net core 2.0 –