简体   繁体   English

客户端JS&服务器端C#通信

[英]Client-side JS & Server-side C# Communication

I've got a web application that's running Js on client side and c# on server side - What would be the best way for them to communicate over the internet and how would I pull that off - would really appreciate some resources, I've been looking around for a bit now and couldn't find anything.我有一个 web 应用程序,它在客户端运行 Js,在服务器端运行 c# - 他们通过互联网进行通信的最佳方式是什么,我将如何实现这一点 - 真的很感激一些资源,我一直现在四处寻找,找不到任何东西。

There wont only be credentials from forms that will be passed through, there will be other data coming from the server time to time as well不仅会传递来自 forms 的凭据,还会不时从服务器传来其他数据

The best answer is WebSocket .最好的答案是WebSocket I believe that there is good support for this in c#, and I know for myself that it's pretty easy to set up in JavaScript.我相信在 c# 中对此有很好的支持,而且我自己知道在 JavaScript 中设置非常容易。 You can use "ws" or a secure connection with "wss".您可以使用“ws”或与“wss”建立安全连接。

The one thing I would warn you about is with "credentials" and sensitive information in JavaScript.我要警告您的一件事是 JavaScript 中的“凭据”和敏感信息。 On the client side, you basically have no control over preventing sensitive information from leaking.在客户端,您基本上无法控制敏感信息的泄露。 Web pages can be altered and inspected by the client. Web 页面可以由客户端更改和检查。 So be careful about what your server sends to your client.所以要小心你的服务器发送给你的客户端的内容。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM