Response.ClearHeaders() 替代 .NET Core

Response.ClearHeaders() replacement for .NET Core

我在控制器操作方法中使用了 Response.ClearHeaders();。但它 returns 错误如:

'HttpResponse' does not contain a definition for 'ClearHeaders' and no accessible extension method 'ClearHeaders' accepting a first argument of type 'HttpResponse' could be found (are you missing a using directive or an assembly reference?)

你能帮忙解决这个问题吗?

改用the Response.Clear() extension method

This invocation resets the response headers, response status code, and response body.