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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:06:14+00:00 2026-06-15T08:06:14+00:00

Off the bat: I am new to using asp.net mvc 4. I am have

  • 0

Off the bat: I am new to using asp.net mvc 4.

I am have a action that creates a excel file and then converts it to PDF.

From View

@Html.ActionLink("Generate Invoice", "genInvoice", new { id = item.invoiceID }) |

Action:

public ActionResult genInvoice(int id = 0)
    {
        var invoiceItems = from k in db.InvoiceItems
                           where k.invoiceID == id
                           select k;

        string invoiceClient = (from kk in db.Invoices
                                where kk.invoiceID == id
                                select kk.clientName).Single();


        invoiceClient = invoiceClient + "_" + DateTime.Now.ToString("ddd dd MMM yyyy hhTmm");
        string websitePath = Request.PhysicalApplicationPath;
        string pathName = websitePath + "\\" + invoiceClient ;
        generateInvoice(invoiceItems, pathName + ".xlsx", id);
        convertToPDF(pathName, invoiceClient);

//Response.AppendHeader("Content-Disposition", "attachment");

          var viewModel = new InvoiceItemAdd();
          viewModel.Invoices = db.Invoices
              .Include(i => i.InvoiceItems)
              .OrderBy(i => i.invoiceID);
        return View("Index", viewModel);
        //return RedirectToAction("Index",viewModel);


    }

Now I want to to eventually download the PDF file and then return to the index view.
It goes to the Index view prints the html etc etc but then the window stays as a white screen with the url: /Invoice/genInvoice/1

Any idea how I can go about doing this? (Going back to the Index view after PDF generation, also downloading it)

  • 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-06-15T08:06:16+00:00Added an answer on June 15, 2026 at 8:06 am

    I am sorry, I fixed the white screen problem. While attempting to do the PDF download

    //Response.AppendHeader("Content-Disposition", "inline; filename="+invoiceClient+".pdf");
                //Return File(output, "application/pdf");
                //Response.Flush();
    
                //Response.End();
    

    Response.End() was not commented out and that stopped it I guess.

    Now the problem is how to open the PDF in a separate tab and return to index in the current
    with the above code.

    EDIT:
    Decided the file can just be downloaded.

    public FileResult genInvoice(int id = 0)
    {
    //More code
    Response.AppendHeader("Content-Disposition", "attachment; filename="+pathName+".pdf");
    return File(websitePath + "\\" + invoiceClient + ".pdf", "application/pdf");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me state off the bat that I'm not that familiar with ASP.Net MVC,
I have a batch script that looks like this: Test.bat @echo off :: Starts
I have this in a batch file called find_java.bat: @echo off for /f delims=
I have bat file like below with name myBat.bat 1) @echo off set CLASSPATH=%CLASSPATH%;C:\Documents
I have created below bat file to run my RMI server @echo Off set
I have this BAT file iARP.BAT Content Begin @ECHO OFF npg -vv -f %1
First off, I would like to make clear, that I am SUPER NEW TO
First I'm brand new to JS but have an idea that object classes are
Let me just say right off the bat that i'm not a programmer. I'm
I am following this tutorial: http://www.generation5.org/content/2001/sr00.asp?Print=1 Right off the bat it asks me to

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.