Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add content-disposition flag #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Rotativa/AsPdfResultBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public string CookieName
set { FormsAuthenticationCookieName = value; }
}

/// <summary>
/// This will be send to the browser as the content disposition telling it how to return the document
/// </summary>
public ContentDisposition ContentDisposition { get; set; }

/// <summary>
/// Custom name of authentication cookie used by forms authentication.
/// </summary>
Expand Down Expand Up @@ -277,8 +282,10 @@ protected HttpResponseBase PrepareResponse(HttpResponseBase response)
{
response.ContentType = ContentType;

string contentDisposition = ContentDisposition == ContentDisposition.Inline ? "inline" : "attachment";

if (!String.IsNullOrEmpty(FileName))
response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", SanitizeFileName(FileName)));
response.AddHeader("Content-Disposition", string.Format("{0}; filename=\"{1}\"", contentDisposition, SanitizeFileName(FileName)));

response.AddHeader("Content-Type", ContentType);

Expand Down
6 changes: 6 additions & 0 deletions Rotativa/Options/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,10 @@ public enum Orientation
Landscape,
Portrait
}

public enum ContentDisposition
{
Attachment,
Inline
}
}