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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:44:12+00:00 2026-06-05T17:44:12+00:00

Hi I need to generate some files on server side and return them to

  • 0

Hi I need to generate some files on server side and return them to client with AJAX

I create next code on server (ASHX)

public void ProcessRequest(HttpContext context)
    {
        string dataViewID = context.Request.Form["dataViewID"];

        MyService service = new MyService();
        var data = service.GetStores(int.Parse(dataViewID), "", null);
        IMyExportService exportservice = new MyExportService();

        HttpContext.Current.Response.ContentType = "application/octet-stream";
        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + "export.cvs");  

        using (var ms = new MemoryStream())
        {
            using (var sw = new StreamWriter(ms))
            {
                exportservice.ExportTo("csv", sw, data);                
                ms.Position = 0;                                                
                HttpContext.Current.Response.Write(ms.ToArray());
            }

        }
    }

on client i create next code:
$(“#btnexport”).click(function () {
var paramData = { “dataViewID”: 1524129, “filter”: “”, extent: null }; //full map
$.ajax({
url: ‘/marketVuePortal/’+’FileExport.ashx’,
type: ‘POST’,
dataType: “json”,
data: {dataViewID:1524129},
success: function (result) {
//what should be here ?
},
error: function (xhr) {
alert(“error”);
}
}
)}

);

But I have 2 problem I don’t know why but I always get error but in debug all code working well. and second is that I don’t know how to say browser that he need save page with out reload.

  • 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-05T17:44:13+00:00Added an answer on June 5, 2026 at 5:44 pm

    /* *
    ——————————————————————– * jQuery-Plugin – $.download – allows for simple get/post requests for files * by Scott Jehl, scott@filamentgroup.com *
    http://www.filamentgroup.com * reference article:
    http://www.filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads/
    * Copyright (c) 2008 Filament Group, Inc * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL
    (filamentgroup.com/examples/gpl-license.txt) licenses. *
    ——————————————————————– */ jQuery.download = function(url, data, method){ //url and data options required if( url && data ){ //data can be string of
    parameters or array/object data = typeof data == ‘string’ ? data :
    jQuery.param(data); //split params into form inputs var inputs =
    ”; jQuery.each(data.split(‘&’), function(){ var pair =
    this.split(‘=’); inputs+=”; }); //send request jQuery(”+inputs+”)
    .appendTo(‘body’).submit().remove(); }; };

    This is solution that I have found.

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

Sidebar

Related Questions

I'm using StringTemplate V4 to generate some HTML code in my project. I need
I have an app which generates some files in the app directories I need
I need to generate a file for Excel, some of the values in this
I need to generate some token that can only take on a range of
I need to generate some 5x6 matrices in MATLAB. They need to consist of
Basically need to generate custom(some different then yes no) messeges(alert) in JS , how
I have this in my controller. I need my view to generate some HTML,
I have the following requirement: Based on some user input, I need to generate
Problem I have some pages that need dynamic data from website to generate output
I'm encountering a problem generating my client and server code from wsdl. I've been

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.