Blazor Dll - 用户可以访问它们并反编译吗?

Blazor Dlls - Can users access them and decompile?

如果我在 Blazor 中遗漏了一些明显的东西,请原谅我,但是如果 dll 像 javascript 文件一样存在于浏览器中,用户是否可以下载 dll 文件并查看执行代码通过在浏览器之外反编译文件 and/or 运行?

如果开发人员不知道他们的库代码是可见的,因为他们的 javascript 代码已经可见,这似乎会带来非常明显的安全问题。

当然可以,那些 DLL 只是 Web 服务器提供的静态文件。我建议阅读 this excellent blog post 了解浏览器如何 运行 这些 DLL:

In interpreted mode, the Mono runtime itself is compiled to WebAssembly, but your .NET assembly files are not. The browser can then load and execute the Mono runtime, which in turn can load and execute standard .NET assemblies (regular .NET .dll files) built by the normal .NET compilation toolchain.

如果您不希望用户(轻松地)对您的代码进行逆向工程,那么答案就是代码混淆。 Blazor does not plan 提供此类功能,任何标准的 .NET 混淆器 都应该 工作。我自己没有尝试过,但我敢肯定这将是一条坎坷的道路。

的确如此。

这是有 2 种 Blazor 风格的部分原因:

  1. Blazor WebAssembly(即客户端 Blazor)
  2. Blazor 服务器

Blazor 服务器应用只会使用以下文件响应浏览器:

  • index.html
  • css
  • blazor.server.js
  • 其他常用的东西(例如img的字体等)

所有的渲染代码和其他代码(你很棒的库和你很棒的代码)都将 运行 在服务器上。

使用 SignalR,浏览器和服务器会一直保持联系(通常通过 websockets),每当 UI 需要改变时,服务器会进行计算并告诉浏览器如何重新渲染UI。由于 blazor.server.js 文件,所有这些魔法都发生在浏览器中。

使用此模式,浏览器上不需要 DLL

现在,当谈到 Blazor WebAssembly(客户端风格)时,您可能不想向浏览器提供任何敏感的专有代码等。当然,您可以始终使用工具来混淆您的代码,但您可能希望在可能的情况下进行 API 调用并在服务器上包含敏感代码 运行。