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

  • Home
  • SEARCH
  • 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 9017469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:16:57+00:00 2026-06-16T04:16:57+00:00

I have something like this in my View: var url = ‘@Url.Action(DownloadZip, Program)’ +

  • 0

I have something like this in my View:

        var url = '@Url.Action("DownloadZip", "Program")' + '?programNums=' + selectedRow;

        $.ajax({
            url: url,
            dataType: 'json',
            async: false,
            success: function (data) {
                if (data != "Successful") {
                    alert(data);
                }
            }
        });

The controller can return a File or can return a JSON result if there was an error.
Haven’t been able to get them both work together.

Here is what it looks like:

    public ActionResult DownloadZip(string programNums)
    {

        if(string.IsNullOrEmpty(programNums))
        {
          return Json("Error, blank info sent.", JsonRequestBehavior.AllowGet);
        }            

        var memoryStream = new MemoryStream();

        using (var zip = new ZipFile())
        {
            zip.AddFile("C:\\sitemap.txt");
            zip.Save(memoryStream);
        }

        memoryStream.Seek(0, 0);
        return File(memoryStream, "application/octet-stream", "archive.zip");

    }

What I am seeing is that the ajax call needs a JSON value back. Since in my case, it returns a File, it cannot work. Anyway to handle what I am doing to where it can give back a JSON or a File from the ajax call.

  • 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-16T04:16:59+00:00Added an answer on June 16, 2026 at 4:16 am

    Have you considered passing back JSON with a file Url?

    If the file is successfully found/created. Send back a JSON result with the link to the file. Then in javascript use windows.location to retrieve the file. When there is an error, the JSON result will contain the error information and this info can be displayed to the user. For this to work, you’ll need to create another endpoint (action) that can stream the file.

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

Sidebar

Related Questions

I'm having some difficulties with Ajax.BeginForm I have something like this in a view
In my view, let's say I have something like this: <%= f.text_field :name_first %>
I have grid something like this: Ext.define('Exp.view.dashboard.Tv', { extend: 'Ext.grid.Panel', initComponent: function() { this.columns
I have a View that renders something like this: Item 1 and Item 2
I have something like this : code.js var params = { option1 : encodeURIComponent(text\n
I have a view with the two HtmlHelpers that produce links, something like this
Has anyone come across something like this before? Basically, I have an action on
I have something like this: function showFunction () { // need position and place
I have something like this: <?xml version=1.0 encoding=utf-8?> <Data> <ConfigDatas> <ArrayOfConfigData xmlns:i=http://www.w3.org/2001/XMLSchema-instance xmlns=http://schemas.datacontract.org/2004/07/BTTest.Models> <ConfigData>
I have something like this: [{'date': 1, 'value':5}, {'date':2,'value':3}, ...] and want to map

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.