Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC : how do I return 304 "Not Modified" status?

ASP.NET MVC 3.0, IIS 7, .NET 4

I have an action that returns data that seldom changes (almost static).

Is there an easy way to:

  1. return 304 "Not Modified" from action;
  2. include "Last-Modified" time stamp in the response.

I use return Content('my data'); for action result.

Basically I want an easy way to do what is talked about in this article : http://weblogs.asp.net/jeff/archive/2009/07/01/304-your-images-from-a-database.aspx

like image 819
THX-1138 Avatar asked Apr 27 '11 20:04

THX-1138


1 Answers

(Very!) late answer but this question pops up near the top in search engine results so it might be useful to future people landing here.

Alternative for part 1:

return new HttpStatusCodeResult(304, "Not Modified");
like image 58
Kntajus Avatar answered Sep 22 '22 09:09

Kntajus