HttpResponse does not contain a definition for AddHeader for Dot Net Core

goamn picture goamn · Apr 3, 2017 · Viewed 7.1k times · Source

When moving a project into .Net Core, AddHeader throws an error:

Error CS1061 'HttpResponse' does not contain a definition for 'AddHeader' and no extension method 'AddHeader' accepting a first argument of type 'HttpResponse' could be found (are you missing a using directive or an assembly reference?) .NETCoreApp,Version=v1.0

Answer

goamn picture goamn · Apr 3, 2017

The answer is to instead do the following (without using AddHeader) :

Response.Headers["key-goes-here"] = "value-goes-here";