You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

LC6464.ASPNET.AddResponseHeaders

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

LC6464.ASPNET.AddResponseHeaders

在 ASP.NET 中用于快速为所有响应添加头的中间件。

1.3.0
Source
nugetNuGet
Version published
Maintainers
1
Created
Source

LC6464.ASPNET.AddResponseHeaders

NuGet 包 GitHub 项目

在 ASP.NET 中快速为所有响应添加头。

使用方法

ExampleWebAPI.csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">
	<PropertyGroup>
		<TargetFramework>net7.0</TargetFramework>
		<Nullable>enable</Nullable>
		<ImplicitUsings>enable</ImplicitUsings>
		<!-- 一些东西 -->
	</PropertyGroup>
	<ItemGroup>
		<PackageReference Include="LC6464.ASPNET.AddResponseHeaders" Version="1.3.0" />
		<!-- PackageReference,请使用 Visual Studio 或 dotnet cli 等工具添加 -->
	</ItemGroup>
	<ItemGroup>
		<Using Include="LC6464.ASPNET.AddResponseHeaders" />
		<!-- 一些别的东西 -->
	</ItemGroup>
</Project>

Program.cs:

var builder = WebApplication.CreateBuilder(args); // 创建 builder


// -------- 添加一些服务 --------


var app = builder.Build();


// -------- 添加一些服务、中间件 --------


app.UseAddResponseHeaders(new HeaderDictionary { // 为每个响应添加头
	{ "Expect-CT", "max-age=31536000; enforce" },
	{ "X-Content-Type-Options", "nosniff" }
});


// -------- 添加一些中间件、运行 WebApplication --------

Keywords

ASP.NET

FAQs

Package last updated on 01 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts