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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:12:51+00:00 2026-05-18T20:12:51+00:00

Using the below code I am unable to show the open/save as file dialog:

  • 0

Using the below code I am unable to show the open/save as file dialog:

        public void ProcessRequest(HttpContext context)
        {
            string link = context.Request.QueryString["Link"];
            string extension = Path.GetExtension(link);
            string fileName = Path.GetFileName(link);
            string fullPath = 
                 String.Format("{0}\\{1}",
                     context.Server.MapPath("~/Content/Uploads/"), 
                     fileName);

            if (File.Exists(fullPath))
            {
                context.Response.ClearContent();
                context.Response.ClearHeaders();
                context.Response.AddHeader(
                    "Content-Length", 
                    new FileInfo(fullPath).Length.ToString());
                string contentType;
                switch (extension)
                {
                    default:
                        contentType = "application/octet-stream";
                        break;
                }
                context.Response.ContentType = contentType;
                context.Response.AddHeader(
                    "Content-Disposition", 
                    String.Format("attachment; filename={0}", fileName));
                context.Response.WriteFile(fullPath, true);
                context.Response.Flush();       
            }
        }

I’ve tried to close the response, leave the response open, use TrasmitFile(), but I never get any dialog or any feed back whatsoever. I’ve tried debugging it as well, but no exceptions are being thrown. Tried in IE 7/8, and Chrome. Any help is appreciated.

Thanks!

Below is the Fiddler output:

HTTP/1.1 200 OK Cache-Control: private
Content-Length: 3813 Content-Type:
application/octet-stream Server:
Microsoft-IIS/7.5 Content-Disposition:
attachment;
filename=b1af9b34-28cc-4479-a056-8c55b41a5ece.txt
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET Date: Thu, 23
Dec 2010 21:51:58 GMT

* Home
* Hotels
* Reviews
* Community
* Travel Guide
* Travel Insurance
* Contact us

* FIDDLER: RawDisplay truncated at 128 characters. Right-click to disable
truncation. *

  • 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-18T20:12:52+00:00Added an answer on May 18, 2026 at 8:12 pm

    Finally figured it out. There is actually no problem with the code I posted. As you can see in the Fiddler output, the contents of the text file were successfully written to the response stream and the headers used were also correct. The actual problem comes from how the actual http request was made. I used a

    $.get(urlToGenericHandler);

    request using jQuery. The reason why specifically I am not able to download a file using AJAX or a callback model is beyond the scope of this answer. See supported jQuery datatypes here

    Anyways, I changed the call from using AJAX to using a basic post-back.

    Thanks to all that helped.

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

Sidebar

Related Questions

I am using below code for inserting data in the database. and i am
I can open contacts,to-do list from mail/usermail.nsf file. But unable to open or access
I am trying to code to capture the packet loss on computers, but the
Error: Unable to read data from the transport connection: A blocking operation was interrupted
So, for the past few days I have been struggling to understand how to
We have a whole catalogue of videos which we would like to stream to
I got this from php.net website. This is related to the problem I am
Like the title says, I've got a Child form being shown with it's TopLevel
What is the best way to create several scrollable regions in an ActionScript 3
We want to have two .NET apps running on the same machine communicate with

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.