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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:20:57+00:00 2026-05-27T01:20:57+00:00

I already know, codes after the Response.End() will not work. I am trying to

  • 0

I already know, codes after the Response.End() will not work. I am trying to alert a message box after Response.End. Basically what i am doing is i will read data from Excel file and check for the missing data in the excel file. I will collect all the data that was missing from the Excel file and write them all to a text file and will prompt that using the following code

string strPath = Server.MapPath("ErrorLog") + "\\" + "ErrorLog.txt";
string FileName = "Errorlog" + ".txt";
string[] createText = { sb.ToString() };
File.WriteAllLines(strPath, createText);
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + "");
strPath.Length.ToString());
HttpContext.Current.Response.ContentType = "application/text";
HttpContext.Current.Response.WriteFile(strPath);
HttpContext.Current.Response.End();

After this i would like to display an alert box saying some thing like Invalid Data. But i would like to know how can i do that after Response.End

// Updated code as per lcarus

string strPath = Server.MapPath("ErrorLog") + "\\" + "ErrorLog.txt";
string[] createText = { sb.ToString() };
File.WriteAllLines(strPath, createText);
ClientScriptManager CSM = Page.ClientScript;
string strconfirm = "<script>if(window.confirm('Excel file has Invalid data.')){window.location.href='/Excel1/ErrorLog/ErrorLog.txt'}</script>";
 CSM.RegisterClientScriptBlock(this.GetType(), "Confirm", strconfirm, false);
  • 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-27T01:20:58+00:00Added an answer on May 27, 2026 at 1:20 am

    You need to do this in sort of 2 parts:

    Collect the missing data, save it to a file (By the way, you need to create a unique name for the log file unless you are planning to support only one concurrent user on your site) and use ClientScript.RegisterStartupScript to call a function like this:

    ClientScript.RegisterStartupScript(this.GetType(),"somekey",
    "alert('Some data missing!'); window.location.href='http://your_site.com/path_to_log_file'",true); 
    

    You will know path_to_log_file since you are the one generating it on the server side.

    The user will see the alert and after clicking “OK” the log file will be displayed on his browser or asked to download it, depending on whether the browser knows how to handle the file (this is usually determined by the extension of the file).

    UPDATE

    Sample HTTPHandler implementation.

    You can construct the link like this from code behind:

    window.location.href='FileDownloader.ashx?FileName=ErrorLog.txt'
    
    public class FileDownloader: IHttpHandler
    {
           public bool IsReusable
           {
                get { return true; }
           }
    
           public void ProcessRequest(HttpContext context)
           {
                // This is where you read the log file and add the content disposition
                //header
                string strPath = Server.MapPath("ErrorLog") + "\\" + context.Request.QueryString["FileName"];
    
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + context.Request.QueryString["FileName"] + "");
                strPath.Length.ToString());
                context.Response.ContentType = "application/text";
                context.Response.WriteFile(strPath);
                context.Response.End();
    
           }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe I already know the answer, but I am not 100% sure, so
How to display xml response already formatted in html (IE won't show anything after
Question: How can I document Ruby code using Doxygen? Disclaimer: I know ruby already
I already know how to: Load properties files into my Spring configuration using: <context:property-placeholder
I already know the obvious answer to this question: just download <insert favorite windows
I already know Java, Objective C, C#, and some Python. I want to be
I already know how to convert the non-utf8-encoded content of a file line by
We already know deflate encoding is a winner over gzip with respect to speed
As you may already know, the .NET Framework's protected internal access modifier works in
I think I already know the answer to this but thought I would ask

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.