外部访问的iis7网站将文件下载到服务器而不是本地机器
我在 IIS 中设置了一个站点。它允许用户将文件从远程云下载到自己的本地桌面。然而,上下文似乎很混乱,因为当我通过 IP 从外部访问网站并执行下载时,它将文件保存到托管该网站的服务器,而不是本地。这是怎么回事??
我的相关行代码:
using (var sw2 = new FileStream(filePath,FileMode.Create))
{
try
{
var request = new RestRequest("drives/{chunk}");
RestResponse resp2 = client.Execute(request);
sw2.Write(resp2.RawBytes, 0, resp2.RawBytes.Length);
}
}
I've a site set up in IIS. It's allows users to download files from a remote cloud to their own local desktop. HOWEVER, the context seems to be mixed up, because when I access the website externally via the IP, and execute the download, it saves the file to the server hosting the site, and not locally. What's going on??
My relevant lines code:
using (var sw2 = new FileStream(filePath,FileMode.Create))
{
try
{
var request = new RestRequest("drives/{chunk}");
RestResponse resp2 = client.Execute(request);
sw2.Write(resp2.RawBytes, 0, resp2.RawBytes.Length);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码正在将文件写入服务器的本地文件系统。如果您想将文件发送到客户端,您需要执行类似的操作。
Response 对象用于将数据发送回向您的页面发出请求的客户端。
Your code is writing a file to the local filesystem of the server. If you want to send the file to the client, you need to do something like
The Response object is what you use to send data back to the client who made the request to your page.
我想您发布的代码片段正在某处的某种代码隐藏中运行。它在服务器上运行 - 它不会在客户端上运行。您需要将这些字节写入响应对象并指定内容类型等,并允许用户自己保存文件。
I imagine that code snippet you posted is running in some sort of code-behind somewhere. That is running on the server - it's not going to be running on the client. You will need to write those bytes in the Response object and specify what content-type, etc. and allow the user to Save the file himself.