ASP.Net发送和接收文件问题
我在这里完全一片空白。我有两台服务器无法通过正常网络流量相互通信(例如复制文件)。由于公司人为安全限制,我无法在任一服务器上设置 FTP。
Server1上基本上只有一个我编写的exe,它需要向Server2发送一个文件。
Server2 上有一个完整的 asp.net 网站,因此我正在编写一个 .ashx 页面来处理接收文件。
所以...Server1 需要调用 server2 并通过 http 向其发送文件。 Server2 需要接受该文件并将其保存到磁盘。
我应该从哪里开始?我知道我可以让 server1 创建一个 WebRequest 对象,并将方法设置为 POST,然后流式传输内容。
但是在server2上,我应该写什么呢?通用处理程序?我发送的文件会成为 context.Request 对象的一部分吗?我怎样才能把它拿出来?
我觉得我错过了一些非常基本的东西,而且无法理解它。
感谢您的指点。
I'm completely blanking here. I've got 2 servers that cannot talk to each other via normal network traffic (like just copying a file). I can't get FTP setup on either server due to artificial company security constraints.
Server1 basically just has an exe on it that I have written, and it needs to send a file to Server2.
Server2 has a full blown asp.net website on it so I'm writing a .ashx page to handle receiving the file.
So...Server1 needs to make a call to server2 and send a file to it over http. Server2 needs to accept the file and save it to disk.
Where should I start? I know I can make server1 create a WebRequest object, and set the method to POST, and then stream the content.
But on server2, what am I supposed to write? A generic handler? Will my file that I send be part of the context.Request object? How do I get it out?
I feel like I'm missing something extremely basic and just can't get my head around it.
Thanks for any pointers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的:您对框架有什么限制吗?如果没有,我强烈建议您采用 WCF 路线并使用 IIS 托管的 WCF 服务来上传文件。
甚至还有一个有用的教程主题。
Ok: do you have any constraints as to framework? If not, I'd highly suggest you go the WCF route and use an IIS-hosted WCF service to upload your file.
There's even a helpful tutorial on the subject.
在 Server2 上创建一个 ASPX 页面并让它托管一个 FileUpload 控件。
从Server1中的exe中,托管一个浏览器控件并请求ASPX页面,并通过文件上传控件上传您想要的文件。
Create an ASPX page on Server2 and let it host a FileUpload control.
From the exe in Server1, host a browser control and request the ASPX page, and upload the file you want via the file upload control.