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

The Archive Base Latest Questions

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

I have handler with this code: HttpRequest request = context.Request; HttpResponse response = context.Response;

  • 0

I have handler with this code:

    HttpRequest request = context.Request;
    HttpResponse response = context.Response;

    if (request["Type"] != null)
    {
        try
        {
            string resultFile = null;
            string fileName = string.Empty;

            int type = Convert.ToInt32(request["Type"]);

            switch (type)
            {
                case 1:
                    fileName = "InnerQuery.doc";
                    resultFile = GenerateInnerQuery(Id);
                    break;

                case 2:
                    fileName = "CourierQuery.doc";
                    resultFile = GenerateCourierQuery(Id);
                    break;

                case 3:
                    fileName = "TransportDogovor.doc";
                    resultFile = GenerateTransportDogovor(Id);
                    break;

                case 4:
                    fileName = "TransportQuery.doc";
                    resultFile = GenerateTransportQuery(Id);
                    break;

                case 5:
                    fileName = "PassQuery.doc";
                    resultFile = GeneratePassQuery(Id);
                    break;
            }

            if (resultFile != null)
            {
                response.Clear();
                response.AddHeader("pragma", "no-cache");
                response.AddHeader("cache-control", "private");
                response.CacheControl = "no-cache";
                response.ContentType = "application/octet-stream";
                response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}",
                    System.Web.HttpUtility.UrlPathEncode(fileName)));
                response.OutputStream.Write(File.ReadAllBytes(resultFile), 0, (int)(new FileInfo(resultFile)).Length);
                response.End();
            }
        }
        catch (Exception ex)
        { }
    }

On client i post data to handler with jQuery.post():

var handler = "GetWord.ashx?Type=6";
    var initiationDateFrom = $("#<%=InitiationDateFromTxt.ClientID%>").val();
    var initiationDateTill = $("#<%=InitiationDateTillTxt.ClientID%>").val();
    var queryDateFrom = $("#<%=QueryDateFromTxt.ClientID%>").val();
    var queryDateTill = $("#<%=QueryDateTillTxt.ClientID%>").val();
    var queryNumber = $("#<%=NumberTxt.ClientID%>").val();
    var initiator = $("#<%=InitiatorTxt.ClientID%>").val();
    var state = $("#<%=StateList.ClientID%>").val();
    $.post(handler,
    {
        InitiationDateFrom: initiationDateFrom,
        InitiationDateTill: initiationDateTill,
        QueryDateFrom: queryDateFrom,
        QueryDateTill: queryDateTill,
        QueryNumber: queryNumber,
        Initiator: initiator,
        State: state
    }, function (data) {
       /*here i should save my file*/
    });

I recieve binary word-file in “data”, but can’t to save it on client.

last time i use:

window.location = handler;

but with jQuery.post it not work.

  • 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-25T20:10:13+00:00Added an answer on May 25, 2026 at 8:10 pm

    When you request the data with an AJAX request, you need to handle it in JavaScript. Saving a file will not be available.

    Instead of using an AJAX request you need to create a form that holds your parameters. Direct the response into an hidden iframe using the target attribute and the browser will offer to save the file.

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

Sidebar

Related Questions

I have this code in a xaml file now in a event handler code
I have this code : <script type=text/javascript> $(document).ready(function() { $('.classSelect').change(function() { // somethings });
I have an OnIdle handler in my D2006 app. With this code: procedure TMainForm.ApplicationEvents1Idle(Sender:
I have a protocol in Objective-C, something like this: @protocol Handler +(NSString*) getValue; @end
I somehow have the feeling that modern systems, including runtime libraries, this exception handler
I have this exact issue ASP.net can’t update page from event handler and it's
I have created a request handler in Solr that uses dismax and limits my
Before I start, I have this code inside of a Custom Usercontrol: private DependencyProperty
I've the following code in my app. MyEventHandler handler = null; //Declare the handler
In some VB6 code, I have a handler for a TreeView's Collapse event: Private

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.