Skip to content

A couple of questions about response headers Server and X-Powered-By #837

Closed
@guardrex

Description

@guardrex

Out of the box, Server and X-Powered-By headers are added to responses ...

Server:Microsoft-IIS/10.0
X-Powered-By:ASP.NET

I tried using an ActionFilterAttribute to dump them ...

public class RemoveHeadersAttribute : ActionFilterAttribute {
    public override void OnActionExecuted(ActionExecutedContext filterContext) {
        filterContext.HttpContext.Response.Headers.Remove("Server");
        filterContext.HttpContext.Response.Headers.Remove("X-Powered-By");
        base.OnActionExecuted(filterContext);
    }
}

... but only the Server header was removed. Is the X-Powered-By header added later in the pipeline? Can it be removed? btw--- Why are these added anyway ... to help MS (others?) track server and programming technology used on the Net?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions