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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:37:13+00:00 2026-06-01T07:37:13+00:00

I haven’t really coded this before but I’ve got a list of file names

  • 0

I haven’t really coded this before but I’ve got a list of file names in my view. There’s a download button next to them. So for example:

enter image description here

here’s the view markup for that:

@foreach (CarFileContent fileContent in ModelCarFiles)
{
    using (Html.BeginForm("GetFileDownloadUrl", "Car", FormMethod.Get, new { carId = Model.CarId, userId = Model.UserId, @fileCdnUrl = fileContent.CdnUrl }))
    {
        @Html.Hidden("userId", Model.UserId);
        @Html.Hidden("carId", Model.CarId);
        @Html.Hidden("fileCdnUrl", fileContent.CdnUrl);        
        <p><input type="submit" name="SubmitCommand" value="download" /> @fileContent.Name</p>
    }
}

When clicked, I send over the CdN url to my action method which under the hood goes and downloads that file from Rackspace and then copies it to our server for the user to download. So my action method returns back the url to the .zip file that the user has now access to download. But when I test this, it’s posting back and redirecting me to a blank page that shows the url rendered in text on the page and that’s it!

"http://www.ourAssetServer.com/assets/20120331002728.zip"

I’m not sure how to invoke a save as prompt instead and keep the user on the same View they are already in or redirect them back to the same view that lists out the files to download…

What I want to happen is this:

  1. User clicks on the download button
  2. Action Method does its thing, downloads the file in the backend
  3. User seemlessly gets a save as pop-up immediately after clicking the download button

this is probably routine but I’ve never done this before. I need help figuring out how to get the save as prompt to show up and how I should handle returning to my View after my action method gets the final download url for the .zip…what do I do with that url in my action method…return it to the view? Not sure here.

here’s the action method:

[HttpGet]
public string GetFileDownloadUrl(string fileCdnUrl int carId, int userId)
{
    string downloadUrl = string.Empty;
    downloadUrl = GetFileZipDownloadUrl(carId, userId, fileCdnUrl);

    return downloadUrl;
}

downloadUrl returned in my action method is that “http://www.ourAssetServer.com/assets/20120331002728.zip” string for example sent back to the user…I just need to figure out how to get this wired up to a save as prompt but also figure out how to handle the view…do I redirect back to the same view or what?
UPDATE:

After researching a bit more, here’s what I came up with:

    [HttpGet]
    public FilePathResult GetFileDownloadUrl(string fileCdnUrl, int carId, int userId)
    {
        string downloadUrl = string.Empty;
        downloadUrl = rackSpaceTask.GetFileZipDownloadUrl(carId, userId, fileCdnUrl);
        int i = downloadUrl.LastIndexOf("/");

        string fileName = downloadUrl.Substring(i);

        return File(downloadUrl, "application/zip", fileName);
    }

I get the error 'http://ourAssetServer.com/assets/20120331002728.zip'; is not a valid virtual path

UPDATE #2

Here’s my latest attempt using the redirect method to try and get a save prompt to show. What’s happening is it is hitting my GetFileDownloadUrl but then never seems to get to my Redirect action method and I end up being redirected to a completely blank page (all white) with the url as http://localhost/Car/GetFileDownloadUrl and just stops there

    @foreach (CarContent fileContent in Model.CarFiles)
    {
        using (Html.BeginForm("GetFileDownloadUrl", "Car", FormMethod.Post, new { carId = Model.CarId, userId = Model.UserId, @fileCdnUrl = fileContent.FileCdnUrl }))
        {
            @Html.Hidden("userId", Model.UserId);
            @Html.Hidden("carId", Model.CarId);
            @Html.Hidden("fileCdnUrl", fileContent.FileCdnUrl);        
            <p><input type="submit" name="SubmitCommand" value="download" /> @fileContent.Name</p>
        }
    }


public void GetFileDownloadUrl(string fileCdnUrl, int carId, int userId)
{
    string cownloadUrl = string.Empty;
    cownloadUrl = GetFileDownloadUrl(carId, userId, fileCdnUrl);

    RedirectToAction("RedirectToUrl", downloadUrl);
}


public ActionResult RedirectToUrl(string fileUrl)
{
    Response.Redirect(fileUrl);
    return null;
}

I’m not sure how the RedirectToUrl should be coded…the return type and what do you return if anything? Should it just redirect keeping me on the page I was on? I don’t “think” this is even being hit, only my first method. I put a debug point on the Response.Redirect and it’s never hit..only a debug point on RedirectToAction(“RedirectToUrl”, downloadUrl);

  • 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-01T07:37:14+00:00Added an answer on June 1, 2026 at 7:37 am

    Consider defining a new action “RedirectToUrl” that takes url as parameter and then using RedirectToAction in your code:

    public ActionResult GetFileDownloadUrl(string fileCdnPath int carId, int userId)
    {
        string downloadUrl = string.Empty;
        downloadUrl = GetFileZipDownloadUrl(carId, userId, fileCdnPath);
    
        return RedirectToAction("RedirectToUrl",
            new { url = downloadUrl });
    }
    

    Update: using the FilePathResult with Server.MapPath is another option (assuming that the server you’re downloading the file to is the same as server running your ASP.NET MVC code). Add the following to the bottom of function in your last edit:

     var assetsPath = Server.MapPath("~/assets");
     var localPath = Path.Combine(assetsPath, zipFileName );
    
     return this.File(localPath, "application/zip");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I haven't found any documentation on this or seen this done before, but is
Haven't really create my own function before, so what I am attempting is to
Haven't fired up reflector to look at the difference but would one expect to
Haven't seen many Geneva related questions yet, I have posted this question in the
Haven't seen anything about it here but it seems to solve one of the
I haven't done a lot of work with multi-level, pure CSS drop-down menus before,
I haven't seen this question anywhere else, I hope someone can help. I have
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Haven't touch javascript for 3 years. Just got a javascript project and wanted to
Haven't seen anything, but I have seen that you can create albums in the

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.