Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm traying to set Etag in response header, but when i check response header in browser i can't see it. By the way this only applies to Etag, i can see another tag and value. By the way i can see it on localhost but when i publish that code to server i cant see.

https://i.stack.imgur.com/j9Aho.png[^]

C#
public static void InsertETag(HttpResponseBase response, Model model)
  {
  

   try
   {
  
    var eTagValue = CalculateETag(model);
    if (!string.IsNullOrEmpty(eTagValue))
    {
   
     
     var matchETagValue = HttpContext.Current.Request.Headers["If-None-Match"];
     if (matchETagValue != null && matchETagValue == eTagValue)
     {
      response.SuppressContent = true;
      response.StatusCode = 304;
      response.StatusDescription = "Not Modified";
      response.Headers["Content-Length"] = "0";
      response.AppendHeader("ETag", eTagValue);
     }
     else
     {
      response.AppendHeader("ETag", eTagValue);
     }
    }
   }
  }


What I have tried:

..........................................
Posted
Updated 11-Apr-23 5:36am
v2
Comments
Dave Kreskowiak 11-Apr-23 10:03am    
DId you set a breakpoint on the inner if statement and make sure the header value we even being set?
Member 14769019 11-Apr-23 10:06am    
Yes, already i tried in local and it worked. I can add any tag and i can see in response header but i can't see only "ETag" tag.

1 solution

You're going to have to get a hold of whoever controls the production server. It may be it is setup to strip or black-list non-standard headers.

Remove Unwanted HTTP Response Headers - Microsoft Community Hub[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900