简体   繁体   English

ASP.NET Core中的AddFileDependency替代

[英]AddFileDependency alternative in asp.net core

I am migrating the following to asp.net core from asp.net mvc. 我将以下内容从asp.net mvc迁移到asp.net核心。

context.Response.AddFileDependency(filePath); context.Response.Cache.SetLastModifiedFromFileDependencies();

Is there an alternative to this or a way to implement the same. 是否有替代方法或实现方法?

I checked the changes in the response header with and without this piece of code and found that this adds a header Last-Modified with a value of last modified datetime of the provided file. 我检查了使用和不使用这段代码的响应标头中的更改,发现这添加了标头Last-Modified ,其值为提供的文件的上次修改日期时间。

Hence, did the following in the asp.net core version. 因此,请在asp.net核心版本中执行以下操作。

var fileInfo = _fileProvider.GetFileInfo(filePath);
context.Response.GetTypedHeaders().LastModified = fileInfo.LastModified;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM