Created
December 8, 2014 05:33
-
-
Save RhysC/651bb54a3c0040085d11 to your computer and use it in GitHub Desktop.
Show file as web page, not an automatic download | MVC Asp.net filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment