简体   繁体   中英

Convert Blazor Server App to Blazor Web-assembly approach

I want to develop an SPA project by Blazor technology.

Due to complexity of debugging the Blazor Web-assembly application, I would like to first create it as a server-side app, and then later change it to a Web-assembly application app.

Is this possible? If so, after I have successfully gotten the Server-side Blazor project to work, what changes will I need to make, to get the same functionality working with the WebAssembly project?

Also, are there any particular approaches or technologies I should avoid in my Server-side Blazor project, because they have no equivalent when using WebAssembly?

For the most part, your Blazor components should be able to migrate from Server to Webassembly with few or no changes.

If your Blazor Server application doesn't require data from outside your application (eg database calls), and it doesn't use any APIs that aren't supported in the browser (eg System.Security.Cryptography), then you may be able to migrate to Blazor Webassembly without any changes to your components.

If your Blazor Server application does require data from outside the browser, then those services will need to be hosted elsewhere and called from your components via Http requests (see Call a web API from ASP.NET Core Blazor ). There are a couple of good options for your Blazor Webassembly back-end, the most common of which is the Blazor Webassembly hosted template. 在此处输入图片说明

If you'd rather serve your Webassembly app as a static web application, you can instead move your back-end services to a serverless function application. There are a variety of options for that, the most convenient of which (in my opinion) is using Azure Static Web Apps with .NET and Blazor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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