Last-Modified Header in Asp.net Core MVC
public class YourController : Controller
{
public ActionResult MyPage(string id)
{
var entity = _db.Get(id);
var headerValue = context.HttpContext.Request.Headers['If-Modified-Since'];
if (headerValue != null)
{
var modifiedSince = DateTime.Parse(headerValue).ToLocalTime();
if (modifiedSince >= entity.UpdatedAt)
{
context.HttpContext.Response.StatusCode = 304;
return new EmptyResult();
}
} // page has been changed.
// generate a view ... // .. and set last modified in the date format specified in the HTTP rfc.
context.HttpContext.Response.AddHeader('Last-Modified', entity.UpdatedAt.ToUniversalTime().ToString("R"));
}
}
Last-Modified Header in Asp.net Core MVC的更多相关文章
- ASP.NET Core MVC/WebAPi 模型绑定探索
前言 相信一直关注我的园友都知道,我写的博文都没有特别枯燥理论性的东西,主要是当每开启一门新的技术之旅时,刚开始就直接去看底层实现原理,第一会感觉索然无味,第二也不明白到底为何要这样做,所以只有当你用 ...
- ASP.NET Core MVC上传、导入、导出知多少
前言 本君已成夜猫子,本节我们来讲讲ASP.NET Core MVC中的上传,这两天才研究批量导入功能,本节顺便简单搞搞导入.导出,等博主弄妥当了再来和大家一并分享. .NET Core MVC上传 ...
- 002.Create a web API with ASP.NET Core MVC and Visual Studio for Windows -- 【在windows上用vs与asp.net core mvc 创建一个 web api 程序】
Create a web API with ASP.NET Core MVC and Visual Studio for Windows 在windows上用vs与asp.net core mvc 创 ...
- ASP.NET Core MVC – Caching Tag Helpers
简介 缓存可以大大提高应用程序加载时间和响应速度.我们可以使用缓存Tag Helpers缓存不会频繁更改的HTML内容. 在上一篇文章中,我们谈到了Tag Helpers,演示Tag Helpers能 ...
- 011.Adding Search to an ASP.NET Core MVC app --【给程序添加搜索功能】
Adding Search to an ASP.NET Core MVC app 给程序添加搜索功能 2017-3-7 7 分钟阅读时长 作者 本文内容 1.Adding Search by genr ...
- 007.Adding a view to an ASP.NET Core MVC app -- 【在asp.net core mvc中添加视图】
Adding a view to an ASP.NET Core MVC app 在asp.net core mvc中添加视图 2017-3-4 7 分钟阅读时长 本文内容 1.Changing vi ...
- 使用 ASP.NET Core MVC 创建 Web API(五)
使用 ASP.NET Core MVC 创建 Web API 使用 ASP.NET Core MVC 创建 Web API(一) 使用 ASP.NET Core MVC 创建 Web API(二) 使 ...
- ASP.NET Core 入门教程 6、ASP.NET Core MVC 视图布局入门
一.前言 1.本教程主要内容 ASP.NET Core MVC (Razor)视图母版页教程 ASP.NET Core MVC (Razor)带有Section的视图母版页教程 ASP.NET Cor ...
- ASP.NET Core 入门教程 4、ASP.NET Core MVC控制器入门
一.前言 1.本教程主要内容 ASP.NET Core MVC控制器简介 ASP.NET Core MVC控制器操作简介 ASP.NET Core MVC控制器操作简介返回类型简介 ASP.NET C ...
随机推荐
- WebFrom基础
ASP.NET WebForm C/S B/S客人 - 用户 要土豆丝 - 给IIS发送请求 ,IIS就相当于是服务员 通知厨房 - IIS把用户要想看到的ASPX告知.NET框架 厨房炒菜 - .n ...
- word2vec相关
word '\xe8\xb6\x85\xe8\x87\xaa\xe7\x84\xb6\xe7\x8e\xb0\xe8\xb1\xa1' not in vocabulary 分词后的样本格式:英雄联盟, ...
- Linux Storage Stack Diagram存储堆栈图
这是一个描述非常好的存储栈,版本为:Linux Storage Stack Diagram v4.10,我在这里转载下图片,可以提升大家对存储栈的理解. https://www.thomas-kren ...
- sql server 全文检索 使用
目前项目中的日志查询 功能 由于长年累月的写入,目前已经达到千万级,对日志进行like 查询,速度可想而知. 此处只讨论 在数据库的优化. 当时 想到两个方案,一个是分区,一个 是全文检索. 分区的话 ...
- jquery的html代码中a的onclick的正确显示的代码
jquery的html代码中a的onclick的正确显示的代码 需要转义一下,试了好久才试出来 img_delete.html('<a onclick="deleteImg(\''+s ...
- javascript的中的new
考察 ECMAScript 语言规范中 new 运算符的定义: The new Operator The production NewExpression : new NewExpression is ...
- Git 知识总结
版本控制git之一 - 仓库管理 版本控制git之二-分支 git https://mp.weixin.qq.com/s/96FS12DTzbjAJQ1ynRNqdg git init 初始化目录 g ...
- VS2017连接Oracle设置
1. 下载安装 Oracle Developer Tools for Visual Studio 2017: 2. 配置tnsnames.ora ODP.Net默认使用安装目录下的 tnsnames. ...
- mac使用备注
快捷键: 掌握好多手势和快捷键可以有效的提高工作效率,触控板和快捷键基本让你可以脱离鼠标. Command+Tab 任意情况下切换应用程序 - 向前循环 Shift ...
- segment_object_model_3d
* *********************************************************************** * This example program sho ...