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

  • Home
  • SEARCH
  • 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 519559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:03:13+00:00 2026-05-13T08:03:13+00:00

I have an MVC Controller with an action public ActionResult GeneratePDF(string id) { FileContentResult

  • 0

I have an MVC Controller with an action

public ActionResult GeneratePDF(string id)
{
      FileContentResult filePath = this.File(pdfBuffer, MediaTypeNames.Application.Pdf);

      return filePath;
}

And for some reason it is taking over 20 seconds when it hits the return line.

The pdfBuffer is working okay, and when I run it on my VS all is okay, but when I deploy to IIS 6 it runs slow.

Anyone know why?

  • 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-13T08:03:14+00:00Added an answer on May 13, 2026 at 8:03 am

    I was running into a similar issue when trying to export to XLS and PDF, the only thing that seem to improve the response time was sending the response directly from the class that generates the file like:

    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.ClearContent();
    HttpContext.Current.Response.ClearHeaders();
    HttpContext.Current.Response.Buffer = true;
    HttpContext.Current.Response.BufferOutput = true;
    HttpContext.Current.Response.ContentType = "application/pdf";
    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + file + ".pdf");
    HttpContext.Current.Response.BinaryWrite(stream.ToArray());
    HttpContext.Current.Response.Flush();
    stream.Close();
    HttpContext.Current.Response.End();
    

    But if you do this you will get a "not all code paths return a value" from the ActionMethod, to avoid that we just send a:

    return new EmptyResult();
    

    This last line will actually never be executed because we end the request directly on the method.

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

Sidebar

Related Questions

I have some doubts regarding the following controller action (in ASP.NET MVC, but it's
guy, i have a page in my asp.net mvc website. the Route configuration: public
In my ASP.NET MVC app, I have an interface which acts as the template
I need urls like /controller/verb/noun/id and my action methods would be verb+noun. For example
How do i map multiple url's to the same action in asp.net mvc I
I am using ASP.NET MVC. My requirement is to build a complex object (an
I have a sample I'm building, that's using the Northwind database. I have a
I am using ASP.NET MVC2 and have a problem. After Log off I manually
In searching I came across ASP.NET MVC page/subpage routing and the wildcard was somewhat
I am creating a site in which I utilize partial views to display various

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.