This is a minor release of WebSharper 9.1. NuGet version 9.1.3.570
.
Templates for .NET Core SDK: dotnet new install WebSharper.Templates::9.1.3.570
Enhancements
-
#1474 support embedding WebSharper content into Razor pages. To enable this
- Use
services.AddWebSharperContent()
in your startup, as well asapp.UseWebSharper()
(or one of its variants). - In your layout page, use
@inject WebSharper.AspNetCore.IWebSharperContentService WebSharperContentService
and add@WebSharperContentService.Head()
to the head section of the page for a placeholder for WebSharper to place initialization scripts. - In your Razor PageModel file (code backend), use the
IWebSharperContentService
service with dependency injection, and then you can create a property that defines a WebSharper content embedded into the page. Here with also creating a named optimized bundle for the page:
public IHtmlContent MyWebSharperControl => _webSharperContentService.Render( WebSharper.Sitelets.Content.Bundle("index", new MyWebSharperControl()));
- Use this property within your page, like
@Model.MyWebSharperControl
. Do not create WebSharper.Web.Controls directly in your Razor expressions as the WebSharper compiler cannot discover them there for preprocessing. - See https://github.com/dotnet-websharper/aspnetmvc for a demo
- Use
-
Also,
app.AddWebSharper()
will now not fail if no sitelet is configured, but will just run remoting and support MVC content. It will also not attempt to load sitelet via reflection by default, unlesswsBuilder.DiscoverSitelet()
is used.
Fixes
- #1473 Fix a dead code elimination issue that could cause page startup problems.
- Tied the version of WebSharper.UI and WebSharper core packages together to the exact version. This can resolve a hidden bug arising from fixes around macros not being applied right when the UI type provider was build with lower version core dlls.