In our ASP.NET Core based web application, we want the following: certain requested file types should get custom ContentType\'s in response. E.g. .map
should map to
Using an overload of OnStarting method:
public async Task Invoke(HttpContext context)
{
context.Response.OnStarting(() =>
{
if (context.Response.StatusCode == (int) HttpStatusCode.OK &&
context.Request.Path.Value.EndsWith(".map"))
{
context.Response.ContentType = "application/json";
}
return Task.CompletedTask;
});
await nextMiddleware.Invoke(context);
}