是否可以在非.NET网站中嵌入Blazor组件? [英] Is it possible to embed a Blazor component in a non .NET website?

查看:126
本文介绍了是否可以在非.NET网站中嵌入Blazor组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望为其中一位客户开发客户端Blazor组件,以将其嵌入到他们网站的页面上.该网站是用Drupal编写的,但实际上我的问题是将Blazor集成到任何非ASP.NET网站中.

We would like to develop a client-side Blazor component for one of our clients to embed on a page in their website. The website is written with Drupal, but really my question refers to integrating Blazor into any non-ASP.NET website.

此图片来自 https://www.nativoplus.studio/blog/blazor-introduction/似乎暗示应该可行,因为没有任何运行时部件依赖于.NET主机:

This image from https://www.nativoplus.studio/blog/blazor-introduction/ seems to suggest that this should be possible as none of the runtime parts are relying on a .NET host:

据我了解,客户端Blazor组件是通过WASM和JavaScript的组合运行的,以便互操作,因此似乎应该可以将Blazor组件嵌入任何网站,而不仅仅是用.NET编写的网站?

As I understand it, a client-side Blazor component is run using a combination of WASM and JavaScript for interop so it seems like it should be possible to embed a Blazor component on any website, not just one written with .NET?

(可能还可能还需要提供Mono.wasm,我不确定这是否仅用于将C#客户端应用程序编译为wasm,还是在运行应用程序时也需要这样做?)

(Possibly Mono.wasm might also need to be also present, I'm not sure if that's only used for compiling our C# client-app to wasm, or if that's needed when running the app too?)

从理论上讲这是可能的,还是我遗漏了一些明显的东西而使它不适合初学者?

Is this theoretically possible, or am I missing something obvious that makes that a non-starter?

如果是这样,谁能举例说明我们需要告诉客户的网站公司将哪些文件添加到站点以及这些文件应位于何处?

If so, could anyone give an example of what files we would need to tell our client's website company to add to the site and where those files should be located?

推荐答案

是.这个有可能.使用dotnet publish发布客户端Blazor应用程序后,可以从任何静态文件托管服务提供结果文件.例如,您可以在发布结果的文件夹中使用http-server .来提供结果.

Yes. This is possible. Once you publish client-side Blazor application using dotnet publish resulting files can be served from any static file hosting. For example you could serve the results using http-server . from the folder where results are published.

要控制Blazor应用程序在最终HTML应用程序中可见的外观,可以根据需要扩展index.html. <app>标签将由Blazor应用程序替换.

To control appearance where Blazor application would be visible in the final HTML application, you can augment index.html as you see fit. <app> tag would be replaced by Blazor application.

这篇关于是否可以在非.NET网站中嵌入Blazor组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆