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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:16:49+00:00 2026-06-12T13:16:49+00:00

I generate a set of letters in a file, but if there are errors

  • 0

I generate a set of letters in a file, but if there are errors then the file may be incomplete. I want to send the file anyway, but with a warning to the user. So I have this:

      string errMessage;
        string filePath = CCGTMarblox.Admin.Helpers.DocumentHelper.GenerateRejectionLetters(grantIDs, out errMessage);

        if (!String.IsNullOrEmpty(errMessage))
        {
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "problem", String.Format("alert('{0}');", errMessage), true);
        }

        if (filePath != null)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);
            Response.ClearHeaders();
            Response.AddHeader("Content-Disposition", string.Format(@"attachment; filename=""{0}""", fileInfo.Name));
            Response.AddHeader("Content-Length", fileInfo.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.TransmitFile(fileInfo.FullName);
            Response.Flush();
        }

The problem is that the the alert is not shown when the code to download the file is included – the headers are cleared and it’s like a new Response. Is there any way I can send the script and the file? I tried to Response.Redirect to a page that retrieves the file, but that didn’t work either.

Actually, what I did in the end was send another start-up script that does a similar task to the redirect that I tried in the question. (I already have a page that handles downloads).

Edit (added after answer was accepted)

string script = String.Format("window.location = '{0}';", url);        
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "goToDownload", script, true);
  • 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-12T13:16:50+00:00Added an answer on June 12, 2026 at 1:16 pm

    I would suggest to have a page which would instruct the users the file download will begin shortly and in this page, you can display any warnings.

    This page would make a separate request for the file, using JS / meta refresh and continue the download. You may also want to provide a direct link, if the download doesn’t begin in specified time.

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

Sidebar

Related Questions

Is it possible to generate a set of wiki pages from XML comment file
How do I do if I want to programatically generate a set of buttons
Given a set of letters, say from A.. F, how can one generate a
Is there any way to randomly generate a set of positive numbers such that
I want to generate a set of non-repeating random numbers from 0...n . e.g:
I'm looking for a way to generate a set of random sided, but regular,
I need to generate a set of coordinates in Erlang. Given one coordinate, say
I'm trying to generate a set of 100 random integers between a fixed range.
I have an WSDL / Web Service and I need to generate an set
Given a string s , what is the fastest method to generate a set

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.