如何设置c# web应用程序的标题



我想为我用c#编写的web应用程序设置一个x-rate-limit头,但我不知道如何做到这一点。有人能帮我吗?

如果您使用的是ASP。这可以在Configure(类Startup)中使用middleware:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.Use(async (context, next) =>
{
// Set what you want
context.Response.Headers.Add("X-Frame-Options", "DENY");
context.Response.Headers.Add("X-Content-Type-Options", "nosniff");
context.Response.Headers.Add("Referrer-Policy", "no-referrer");
// Important, without this line you create a "short circuit" to terminate your request.
await next();
});
// Other stuff
}

最新更新