Handle HTTP-Headers and status codes in controller

2019-07-31 11:17发布

问题:

Im currently polling data with from an Database with an regular interval. For the backend I'm using C# and MVC2 as framework. As I'm fetching data with an interval of 10 seconds now I would like to in the backend in my controller implement some kind of conditional that will parse the http header and not fetch the data again if it has not been modified since last fetch. I'm not really sure how I would go about with this. Anyone have any good suggestions?!

Regards

回答1:

Why mess around with http headers for this? Just use the OutputCache attribute - this is exactly what it's for.