Response.TransmitFile() 抛出“访问路径 {path} 被拒绝”使用 ASP.NET 开发服务器

发布于 2024-10-17 03:56:45 字数 419 浏览 4 评论 0原文

我正在尝试使用 Response.TransmitFile() 发送受保护的 PDF 文件(无法直接通过浏览器访问),但收到“访问路径...被拒绝”的消息。我正在使用 ASP.NET 开发服务器,因此我不确切知道正在使用哪个用户帐户。无论如何,我已经为每个人设置了完全控制,但仍然没有运气。

可能是什么原因造成的?也许甚至与权限无关...

我正在使用的代码如下,我不确定是否可以。

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content–Disposition", "attachment; filename=foo.pdf");
Response.TransmitFile(file);
Response.End();

I'm trying to send a protected PDF file (which cannot be accesed directly via the browser) using Response.TransmitFile() but I'm getting "Access to the path ... is denied". I'm using ASP.NET Development Server so I don't know exactly which is the user account that's being used. Anyway I've set Full control for Everyone but still no luck.

What could be causing this? Maybe is not even related to permissions...

The code I'm using is the following, which I'm not sure if it's ok.

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content–Disposition", "attachment; filename=foo.pdf");
Response.TransmitFile(file);
Response.End();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随梦而飞# 2024-10-24 03:56:45

算了……我的路径有错误(不存在)。我讨厌路径=P

Forget it... I had an error in the path (did not exists). I hate paths =P

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文