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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:44:29+00:00 2026-05-15T02:44:29+00:00

My app needs to download a file after the file has been cached and

  • 0

My app needs to download a file after the file has been cached and then download the file. I have one jQuery.post() cache the file and then call the following after the file is successfully cached:

<script type="text/javascript">
    function startViewingFiles(fileNames) {
        $.get(
            '<%= Url.Action(MvcTemplates.Document.DisplayDownload()) %>',
            { fileName: fileNames[0] },
            function() {
                $('<div class="status fill"><p>Download complete</p></div>')
                    .appendTo('#ViewerContainer')
                    .fadeIn('slow'); 
            }
        );
    }
</script>

This communicates with the following action, as I have observed the calls actually make it to the server in VS 2008 and the FilePathResult exits the method successfully:

[HttpGet]
public virtual ActionResult DisplayDownload(string fileName)
{
    var path = _CacheService.GetCachedPath(fileName);
    return new FilePathResult(path, _MimeDictionary.LookupMimeType(fileName));
}

Using Firebug, I see the response contains a “500 Internal Server Error” that complains of a System.UnauthorizedAccessException: Access to the path 'C:\websites\WebSubscriptionPortal\CacheLocation' is denied. I configured both the VS development server and the web app in IIS 7.5 to run as my user with full access to the directory, but I always get this error. When I have the view output WindowsIdentity.GetCurrent().Name, it outputs my user name regardless of which server I use.

  1. Why am I getting the UnauthorizedAccessException?
  2. Apparently, I cannot use jQuery to download a file using FilePathResult. Is this true?
  3. Do I need to change the method used on the client or the ActionResult on the server to start the download via a Javascript method?

Update: The UnauthorizedAccessException exception is due the fact that the fileNames parameter is null, as no route was setup to map to a method with a parameter named “fileNames”. So the path parameter to the FilePathResult constructor is simply the directory name as shown in the exception message.

  • 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-15T02:44:30+00:00Added an answer on May 15, 2026 at 2:44 am

    No. You cannot use jQuery to return a file via download. You can, however, set location.href to the action that delivers the file and it will download it without changing the current page. This assumes that the FileResult is an attachment, which it typically is. You should change the method on the client to use location.href instead of jQuery get. I’m not sure why you are getting the access exception. It could be that while you have access to the particular directory, your account doesn’t have access to one of the intervening directories in the path.

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

Sidebar

Related Questions

My app needs to have multiple screen e.g. one login page then another page
I have a flash app that needs to download a file, whose name contains
When my app is initially downloaded, the user needs to download a large file
If I have a large file download going on an the app gets moved
In my AIR app, I have a list of file that needs to be
I have an app that needs to open an XPS file. I can use
I have a .net client app that needs to play some content (images, movies,
my app needs to download some data (about 50k) on launch time. I'm currently
I have an app that allows the user to cache data for offline use.
i will like to know how do i call didFinishLaunchingWithOptions again after in app

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.