Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 903123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:49:29+00:00 2026-05-15T15:49:29+00:00

To send pdf files (or any other file type) to the browser, I’ve seen

  • 0

To send pdf files (or any other file type) to the browser, I’ve seen examples that use the FileResult class or a custom Action Result.

Is there an advantage of using one over the other? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:49:30+00:00Added an answer on May 15, 2026 at 3:49 pm

    EDIT Original reply removed.

    I’m not sure if the exist file result allows to you modify the content disposition, I believe it forces the content disposition of “attachment”. If you want to use a different disposition, I’d implement a custom Action Filter:

    /// <summary>
    /// Defines an <see cref="ActionResult" /> that allows the output of an inline file.
    /// </summary>
    public class InlineFileResult : FileContentResult
    {
        #region Constructors
        /// <summary>
        /// Writes the binary content as an inline file.
        /// </summary>
        /// <param name="data">The data to be written to the output stream.</param>
        /// <param name="contentType">The content type of the data.</param>
        /// <param name="fileName">The filename of the inline file.</param>
        public InlineFileResult(byte[] data, string contentType, string fileName)
            : base(data, contentType)
        {
            FileDownloadName = fileName;
        }
        #endregion
    
        #region Methods
        /// <summary>
        /// Executes the result, by writing the contents of the file to the output stream.
        /// </summary>
        /// <param name="context">The context of the controller.</param>
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null) {
                throw new ArgumentNullException("context");
            }
    
            HttpResponseBase response = context.HttpContext.Response;
            response.ContentType = this.ContentType;
            if (!string.IsNullOrEmpty(this.FileDownloadName)) {
                ContentDisposition disposition = new ContentDisposition();
                disposition.FileName = FileDownloadName;
                disposition.Inline = true;
                context.HttpContext.Response.AddHeader("Content-Disposition", disposition.ToString());
            }
    
            WriteFile(response);
        }
        #endregion
    }
    

    That is one I’ve used previously, because I pass the actual byte[] data of the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a websercive in C# that will generate pdf-files and send back to
I have a program that generates a PDF as output. If I send this
We currently use PDForm to grab a blank pdf file (no values, just form
Assuming that I have all the details of a PDF file (file name, printer
We're using a 3rd party XML messaging service that requires an embedded PDF file
I need to send an image as in form of PDF file in my
I got this servlet which return a pdf file to the client web browser.
Does anyone have any examples of starting the file stream before the rendering/building process
I use this code to send an PDF through PHP to the visitor ([link][1]):
I have a C# process that prints an in memory pdf file using O2S.Components.PDFRender4NET,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.