User-1273603057 posted
The code below produces the following Web browser results:
Server=Microsoft-IIS/10.0
my-header=*
Hello World!
using System.Linq;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
namespace WebAppLight
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
private const string CR = "<BR>";
public void Configure(IApplicationBuilder app)
{
app.Use(async (context, next) =>
{
context.Response.Headers.Append("my-header", "*");
await next();
});
app.Run(async (context) =>
{
var headerString = string.Join(CR,
context.Response.Headers
.Select(r => r.Key + "=" + r.Value.First()));
await context.Response.WriteAsync(headerString+CR);
await context.Response.WriteAsync("Hello World!");
});
}
}
}