asp.net-mvc-3filterhttp-headershttpresponseif-modified-since

If-modified-since header with filters and MVC3


I just saw some examples about implementing the if-modified-since header. I really don't understand how it works very well. I have seen this example and it seems that if I set a date value to the header "Last-Modified", then I will get a value for the header "If-Modified-Since" if I check it later, am I right?

Also, It seems that, even though he provides a helper, I have to use it in every action?

I also looked into this post. He created a filter to handle the "If-Modified-Since" header. However, I don't understand much what he is trying to do in there, but as I can see, if the "Last-Modified" and "If-Modified-Since" headers are null then it will read it as dateModified = true and then it won't do anything inside the filter. Therefore, I think it depends on setting those header values in every action?

FInally,I'm not so sure about how should I use it, I think that I should send a new "Last-Modified" date value whenever I make an update to the view, is this the right aproach?


Solution

  • I came into your question and you actually helped me resolving the same problem you were having.

    I'm going to explain you what happens with the header and what I've done to resolve it in C#:

    Hope this helps