<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>
这与以下操作进行通信,正如我观察到的那样,在VS 2008中调用实际上是对服务器的调用,并且FilePathResult成功地退出了该方法:
[HttpGet]
public virtual ActionResult DisplayDownload(string fileName)
{
var path = _CacheService.GetCachedPath(fileName);
return new FilePathResult(path, _MimeDictionary.LookupMimeType(fileName));
}
System.UnauthorizedAccessException: Access to the path 'C:\websites\WebSubscriptionPortal\CacheLocation' is denied.
我在iis7.5中配置了vsdevelopment服务器和web应用程序,以完全访问目录的用户身份运行,但我总是遇到这个错误。当我有了视图输出
WindowsIdentity.GetCurrent().Name
-
为什么我会得到
UnauthorizedAccessException
-
显然,我不能使用jQuery下载文件
FilePathResult
. 这是真的吗?
-
ActionResult
在服务器上通过Javascript方法开始下载?
更新:
这个
未授权访问例外
例外情况是由于
fileNames
path
文件路径结果
构造函数只是异常消息中显示的目录名。