更新时间:2023-02-15 22:14:57
否.您不能使用jQuery通过下载返回文件.但是,您可以将location.href
设置为传递文件的操作,它将在不更改当前页面的情况下下载文件.假定FileResult是附件,通常是附件.您应该在客户端上更改方法以使用location.href
而不是jQuery get
.我不确定为什么会出现访问异常.可能是,虽然您有权访问特定目录,但您的帐户却无权访问路径中的中间目录之一.
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.