csharp 将文件显示为网页,而不是自动下载| MVC Asp.net过滤器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 将文件显示为网页,而不是自动下载| MVC Asp.net过滤器相关的知识,希望对你有一定的参考价值。

public class InlineFileAttribute : ActionFilterAttribute
{
    private const string ContentDisposition = "Content-Disposition";

    public override void OnResultExecuted(ResultExecutedContext filterContext)
    {
        var headers = filterContext.HttpContext.Response.Headers;
        if (!string.IsNullOrWhiteSpace(headers[ContentDisposition]))
            headers[ContentDisposition] = headers[ContentDisposition].Replace("attachment", "inline");
        base.OnResultExecuted(filterContext);
    }
}

以上是关于csharp 将文件显示为网页,而不是自动下载| MVC Asp.net过滤器的主要内容,如果未能解决你的问题,请参考以下文章

显示文件结构而不是实际网页的应用服务 Web 应用

如何将一个网页以及包含的文件全部整站下载到本地电脑里?

Google Chrome打开pdf文件跳出下载界面怎么解决?

在 chrome 中自动打印/保存网页为 pdf - python 2.7

图片 url 下载图片而不是显示它

能把网页中打开的pdf文件直接保存下来而不使用下载吗?