Can we add the extra http response header item example "Last Updated" beside the default response header?
example when I call (Request):
localHost:12345/API/GetInfo
with header:
Host: localHost:12345
......
then the api will reply the header with(Response):
HTTP/1.1 200 OK
Content-Length: XX
Content-Type: XXX
Last-Update: The value and the value generate from the API function
Select the web site where you want to add the custom HTTP response header. In the web site pane, double-click HTTP Response Headers in the IIS section. In the actions pane, select Add. In the Name box, type the custom HTTP header name.
If you want to set a custom HTTP headers on your server to be sent in your HTTP responses, the process is quite simple. We have outlined below the snippets required to add a custom header for both Apache and Nginx web servers.
You can set response headers, you can add response headers. And you can wonder what the difference is. But think about it for a second, then do this exercise. Draw a line from the HttpResponse method to the method's behavior.
A response header is an HTTP header that can be used in an HTTP response and that doesn't relate to the content of the message. Response headers, like Age , Location or Server are used to give a more detailed context of the response.
You can add header by using this code:
HttpContext.Current.Response.AppendHeader("Last-Update", value);
FYI there is an official HTTP Header that you can use to represent the DateTime a resource was last updated.
It is the 'Last-Modified' Header (See section 14.29 on Section 14 page of the specification).
You add it to your response like this:
Response.Content.Headers.LastModified = yourResource.LastUpdatedDateTime;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With