I only have, currently, the Oxygene compiler, but I would like to know the answer to this question:
If I have Remobjects C# and Oxygene, is it possible to have a Blazor application with the code behind files in Oxygene?
We don’t currently have any official support for Blazor. At all. It’s also still in “Preview 1” mode, so I’m not sure if its worth us investing much in supporting it yet.
If you have Oxygene and RemObjects C# (i.e. full Elements), you can use Razor and
.cshtml files. Whether and how well that support works for Blazor at this stage is up fro grabs.
The alternative to Blazor I am planning to use is WebAssembly for client-side code combined with WebServices for the server-side code.
Blazor server is supported on .NET Core 3.0. It’s Blazor client that’s still in preview.
Then maybe I’m confused tat Blazor means. I tough Razor was server-side .cshtml (that works), and Blazor is the WebAssembly (ie by definition, client) part?
Right for Razor that is the language used in .cshtml.
Blazor exists in two flavours:
- Server side, where the server does all the work and returns the changes in the DOM to the client using a SignalR connection.
- Client side: this is the web assembly version.
For more information: https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-3.1
Gotcha. I’d expect server-side should “just work” (but feedback appreciated; if you find any issues I’ll be happy to look into fixing them ASAP).
client-side might also just work, or might not (though usually, these days, .NET ha so many special hacks for everything that it probably won’t, out of the box). If you give it a try, id love to hear now far it gets and what fails, as I’ll be looking at supporting this eventually, too, but more long short term.
It works almost with a C# main project in the solution. The only problem I have is https://talk.remobjects.com/t/problem-publishing-a-blazor-client-application-with-oxygene-assemblies/21893/17
But I would like to write the code-behind files in Oxygene instead of C#, so my question in this thread (I cannot test because I don’t have a licence of RemObjects C#.)
You can write the
.cshml.pas in Oxygene; the
.cshtml itself needs to be C#, and we don’t/won’t support any other languages; this should work with the 30-day trial for C#, fwiw.
How can I activate the 30-day trial for C#, to have a look, as I’m registered only for Oxygene?
It should activate itself the first time you use C#.
When I create a Blazor client application, VS creates a .csproj file that is tied to Visual C# and there is no way to add an Oxygene file to it.
The default .csproj file is:
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netstandard2.1</TargetFramework> <RazorLangVersion>3.0</RazorLangVersion> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-rc1.20223.4" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-rc1.20223.4" PrivateAssets="all" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-rc1.20223.4" PrivateAssets="all" /> <PackageReference Include="System.Net.Http.Json" Version="3.2.0-rc1.20217.1" /> </ItemGroup> </Project>
I did mention that we don’t officially support Blazor yet, right? That includes not having a project template for it; you will need to sort this our yourself start with (for example) a project created with the Razor template, and make the necessary adjustments/add the necessary files to make it match what VC# does.
Ok, that should match what you get when you create a new Oxygene ASP.NET project from template. Do that, add the references, add the same (kind of) files that the VC# project has (and convert the .cs ones to .pas, as you see fit), and off you go.