简体   繁体   English

C#winforms客户端:如何在服务器端经过验证的条件下下载文件?

[英]C# winforms client: How can I download file under conditions validated on server side?

In our solution we have a winforms client and a web application with a database. 在我们的解决方案中,我们有一个winforms客户端和一个带有数据库的Web应用程序。 We use WCF as the main way to communicate and perform certain actions on the server and all works well but now we need to implement a way to download fairly large files (~ couple of 100MB) under conditions that need to be validated on the server side (otherwise bypassing the client would enable unconditional downloads). 我们使用WCF作为在服务器上进行通信和执行某些操作的主要方法,并且一切正常,但是现在我们需要实现一种在需要在服务器端进行验证的条件下下载相当大的文件(大约100MB)的方法。 (否则绕过客户端将启用无条件下载)。

The most obvious and desirable solution (at least for the validation part) is a WCF service. WCF服务是最明显且最理想的解决方案(至少对于验证部分而言)。 But for downloading files configuration seems quite involved when it comes to large files, and there are important settings and options that I would not be comfortable to deploy without fully understanding them. 但是对于大文件来说,下载文件的配置似乎相当复杂,并且有一些重要的设置和选项,如果不完全了解它们,我将不愿意部署它们。

With WebRequest or WebClient I cannot see any way to perform validation on the server. 使用WebRequest或WebClient,我看不到任何在服务器上执行验证的方法。

Is there any simple way to achieve this? 有没有简单的方法可以做到这一点?

If WCF is the way can anyone show me how to implement this correctly and safely? 如果使用WCF,谁能告诉我如何正确,安全地实现此功能?

WCF allows to stream response so you can use it to download large file/data set. WCF允许流式响应,因此您可以使用它来下载大文件/数据集。 Please read this article to learn how to work with streaming. 请阅读本文,以了解如何使用流媒体。 The same but in another words and with sample code: Streaming files over WCF 相同,但换句话说,并带有示例代码: 通过WCF流​​式传输文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C#中的应用程序中在客户端获取远程服务器的日期和时间? - How can I get the remote server's date and time at the client side in my application in c#? 如何通过 JavaScript 从服务器端的 Z2567A5EC9705EB7AC2C98403 - How can I call client side C# program function via JavaScript from web page on server side? 如何过滤 C# .net 客户端中的记录? - How can I filter the records in C# .net client side? gRPC c# 文件下载/上传 + web 客户端 - gRPC c# file download/upload + web client side 如何通过按C#中的按钮在另一个下方动态添加文本框? (winforms) - How can I add a text box dynamically under an other by pressing a button in c#? (winforms) 如何使用 c# winforms 从 ftp 文件夹下载所有文件? - How can I download all files from a ftp folder with c# winforms? 如何使用C#/ WinForms从Gmail下载电子邮件? - How can I download emails from Gmail using C#/WinForms? C#将文件上传到服务器-客户端和服务器端 - C# upload file to server - both client and server side 如何请求客户端确认在服务器端执行操作(如发送电子邮件)ASP.NET C# - How can I ask for client confirmation to perform an action (like sending an email) on server side ASP.NET C# 使用C#应用程序客户端在服务器上使用文件和文件夹 - working with file&folder on server with c# application client side
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM