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 (e.g. database calls), and it doesn't use any APIs that aren't supported in the browser (e.g. 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
Related
We have a legacy Web Forms app that we intend to slowly port over, module by module, to Blazor WASM. As we do not have the capacity to rebuild everything in Blazor straight away, we are going to have to run the Blazor and Web Forms app side by side for the time being. To the end user, this needs to appear seamless - i.e. they don't notice when they're being switched between the two.
The first thing I am trying to sort out is the log in process. We have decided to use IdentityServer to build an external identity provider which both the Blazor and Web Forms app will communicate with. Currently I am just trying to create some proof of concept models to see if I can actually get this to work.
I have managed to build a sample Blazor WASM app and a sample Web Forms app that both communicate with the same IdentityServer app to log in. Both of these apps recoginise upon initial load whether a user is already logged in to IdentityServer or not and they show or hide a claims page accordingly.
If I log out of the Web Forms app and then refresh the page in the Blazor app, the Blazor app requires me to log in again - which is what I want. I'm doing this by setting:
BackChannelLogoutUri = "https://localhost:7260/bff/backchannel"
in the IdentityServer Config.cs file for my Blazor client.
What I can't work out is how to get my Web Forms app to behave in a similar fashion. If I log out of my Blazor app, the Web Forms app remains signed in. I am not sure what the equivalent FrontChannelLogoutUri or BackChannelLogoutUri would be for the Web Forms app.
The Web Forms sample app I am using as my template is the sample provided by Duende themselves, which is here:
https://github.com/DuendeSoftware/Samples/tree/main/various/clients/Owin
(Firstly, these "technology migration" projects are tough , so I wish you the best of luck!)
You need a have two "Front channel server-side clients", so the BackChannelLogoutUri setting is useless. So you need to pay attention to this part of the Identity Server documentation.
Alternatively (as I have done the same in a similar project) you can call a service api in the other UI client and then use a technology like SignalR to notify all open browser tabs of the logging-out user in any other UI to trigger log out.
I am already having a react SPA which works with backend WebAPI.
Currently, I am making an ASP.NET Core MVC Project which has its own view pages, but needs to integrate this app in one page (I will integrate all WebAPI functions to this MVC app as well).
Since I am using Cookie based authentication on my ASP.NET Core App, I want my react app to share the same authentication session so that users doesn't need to login again.
Theoretically, everything should work well when I copy the compiled react JS files to my ASP.NET Core scripts folder and run it.
But, The challenge is debugging. When both apps works on different ports, the Authentication cookie is not shared, and my react app will not work (Both CORS and Authentication problem)
How can I run both apps on same port while development?
I want to have a server web app that serves the code for a Blazor WebAssembly app and also uses controllers to serve data.
So, in a single server app (and in a single executable file), I want to pack the Blazor code that ships to the browser and also have the controllers to respond to HTTP requests.
I was expecting this to be easy to do, but I am honestly lost trying to find how to do this.
The Blazor WASM templates in Visual Studio don't seem to allow this out-of-the-box (the hosting model and what you can do with it is completely different from what you have in web apps) and searching online did not provide any helpful samples on how to do this.
Has anyone done this before?
Note:
I have started with a Blazor app and tried adding controller support to it. Not sure if starting with a web app and trying to add Blazor WebAssembly functionality to it would be easier, but I doubt it...
I've fiddled with Backend Servers using NodeJS in the past and want to build a Web API for a game. I also want that same Web Server to have a Front-end page (For logging in and changing some data the Web API needs for requests, basically).
I'd like the API to be available via localhost/api/v1/.. and currently have a React Page for the Login stuff ect (using the ASP.Net core React template).
How would I go adding in the Web API part? If I understood correct, the ASP.Net Core React template creates both a react front-end and ASP.Net Core back-end already?
Is there any integration meteor application with application server.
I want to create a chat client which should be integrated with my web application, i have seen meteor example and i want to explore the possibility for my requirement.
Please suggest.
You could either use meteor for your web application or you could put the meteor chat application in an iframe on your web application.
It would be difficult to actually integrate your current web application into a seperate meteor instance because meteor includes its own webserver and the meteor code can't run on what your application server's stack might be (IIS/Apache,Thin,etc). You would have to look at a way of having meteor run on its own and then integrating this into your webpage with html/javascript
If you don't have a chat application on meteor yet, there's a very good example at:
https://github.com/AVGP/meteor.js-chat-example