Using ASP.NET MVC, can I download a file using a jQuery GET and FilePathResult?
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?


Using ASP.NET MVC, can I download a file using a jQuery GET and FilePathResult?
===

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?

