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 1104547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:29:59+00:00 2026-05-17T01:29:59+00:00

I have an ASP.NET MVC2 application in development and I am having problems rendering

  • 0

I have an ASP.NET MVC2 application in development and I am having problems rendering a .pdf file from our production server.

On my Visual Studio 2010 integrated development server everything works fine, but after I publish the application to the production server, it breaks. It does not throw any exceptions or errors of any kind, it simply does not show the file.

Here’s my function for displaying the PDF document:

public static void PrintExt(byte[] FileToShow, String TempFileName, 
                                                       String Extension)
{
    String ReportPath = Path.GetTempFileName() + '.' + Extension;

    BinaryWriter bwriter = 
        new BinaryWriter(System.IO.File.Open(ReportPath, FileMode.Create));
    bwriter.Write(FileToShow);
    bwriter.Close();

    System.Diagnostics.Process p = new System.Diagnostics.Process();
    p.StartInfo.FileName = ReportPath;
    p.StartInfo.UseShellExecute = true;
    p.Start();
}

My production server is running Windows Server 2008 and IIS 7.

  • 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-17T01:29:59+00:00Added an answer on May 17, 2026 at 1:29 am

    You cannot expect opening the default program associated with PDF file browsing on the server. Try returning the file into the response stream which will effectively open it on the client machine:

    public ActionResult ShowPdf()
    {
        byte[] fileToShow = FetchPdfFile();
        return File(fileToShow, "application/pdf", "report.pdf");
    }
    

    And now navigate to /somecontroller/showPdf. If you want the PDF opening inside the browser instead of showing the download dialog you may try adding the following to the controller action before returning:

    Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET application that we've written our own logging module for. My
So I have ASP.NET running on the server in IIS7. I think I'm going
I have an Asp.NET application (VS2008, Framework 2.0). When I try to set a
I have a ASP.NET 1.1 application, and I'm trying to find out why when
In my latest ASP.NET MVC 2 application I have been trying to put into
I have an ASP.NET MVC 2 application, which has an Application_Error event handler in
I have ASP.NET web pages for which I want to build automated tests (using
I have asp.net form that contains fields. When I access this window, my javascript
I have ASP.Net code similar to the following (this is inside a FIELDSET): <ol>
I have a ASP.NET page with an asp:button that is not visible. I can't

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.