{"id":298238,"date":"2020-02-05T09:00:31","date_gmt":"2020-02-05T09:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298238"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298238","title":{"rendered":"Blazor WebAssembly 3.2.0 Preview 1 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/microsoft\/blog\/486638\/\">\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Blazor WebAssembly \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0412\u043e\u0442 \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435:<\/p>\n<ul>\n<li>\u0412\u0435\u0440\u0441\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0434\u043e 3.2<\/li>\n<li>\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a<\/li>\n<li>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/li>\n<li>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 .NET SignalR<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ur\/ko\/lb\/urkolb1apkzkcs3kq3wh-t9py7w.jpeg\"><a name=\"habracut\"><\/a><\/p>\n<h2>\u041d\u0430\u0447\u0430\u043b\u043e<\/h2>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 Blazor WebAssembly 3.2.0 Preview 1\u00a0<a href=\"https:\/\/dotnet.microsoft.com\/download\/dotnet-core\/3.1\">\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 .NET Core 3.1 SDK<\/a>\u00a0\u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"plaintext\">dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.2.0-preview1.20073.1<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435! \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0430\u00a0<a href=\"https:\/\/blazor.net\/\">https:\/\/blazor.net<\/a>.<\/p>\n<h2>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/h2>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Blazor WebAssembly \u0441 3.1.0 Preview 4 \u0434\u043e 3.2.0 Preview 1:<\/p>\n<ul>\n<li>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u044b Microsoft.AspNetCore.Blazor* \u043d\u0430 3.2.0-preview1.20073.1.<\/li>\n<li>\u0412\u00a0<i>Program.cs<\/i>\u00a0\u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 Blazor WebAssembly \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435\u00a0<code>BlazorWebAssemblyHost.CreateDefaultBuilder()<\/code>\u00a0\u043d\u0430\u00a0<code>WebAssemblyHostBuilder.CreateDefault()<\/code>.<\/li>\n<li>\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 Blazor WebAssembly \u0438\u0437\u00a0<code>Startup.Configure<\/code>\u00a0\u0432\u00a0<i>Program.cs<\/i>\u00a0\u0432\u044b\u0437\u0432\u0430\u0432\u00a0<code>builder.RootComponents.Add&lt;TComponent&gt;(\u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0441\u0442\u0440\u043e\u043a)<\/code>.<\/li>\n<li>\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u0443\u0436\u0431\u044b \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 Blazor WebAssembly \u0438\u0437\u00a0<code>Startup.ConfigureServices<\/code>\u00a0\u0432\u00a0<i>Program.cs<\/i>\u00a0\u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e\u00a0<code>builder.Services<\/code>.<\/li>\n<li>\u0423\u0434\u0430\u043b\u0438\u0442\u0435\u00a0<i>Startup.cs<\/i>\u00a0\u0438\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Blazor WebAssembly client project.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442\u0435 Blazor WebAssembly \u0441 ASP.NET Core, \u0432 \u0432\u0430\u0448\u0435\u043c\u00a0<i>Server<\/i>\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u00a0<code>app.UseClientSideBlazorFiles&lt;Client.Startup&gt;(...)<\/code>\u00a0\u043d\u0430\u00a0<code>app.UseClientSideBlazorFiles&lt;Client.Program&gt;(...)<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0412\u0435\u0440\u0441\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0434\u043e 3.2<\/h2>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 Blazor WebAssembly \u0434\u043e 3.2, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u0438\u0445 \u043e\u0442 \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430 .NET Core 3.1 Long Term Support (LTS). \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430 .NET Core 3.2 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u2014 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f 3.2 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a Blazor WebAssembly. Blazor WebAssembly \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 .NET Core 3.1, \u043d\u043e \u043d\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 .NET Core 3.1 LTS. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u043f\u0443\u0441\u043a Blazor WebAssembly, \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043c\u0430\u0439 \u044d\u0442\u043e\u0433\u043e \u0433\u043e\u0434\u0430, \u0431\u0443\u0434\u0435\u0442 <i> Current<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u00ab\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043f\u043e\u0441\u043b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430 Current \u0438\u043b\u0438 LTS\u00bb, \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 <a href=\"https:\/\/dotnet.microsoft.com\/platform\/support\/policy\/dotnet-core\">.\u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 .NET Core <\/a>. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u043f\u0443\u0441\u043a Blazor WebAssembly \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u0443\u0441\u043a\u0430 3.2 \u0432 \u043c\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441 <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/introduction-net-5\/\"> .NET 5 <\/a>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 .NET 5 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Blazor WebAssembly \u0434\u043e .NET 5, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e.<\/p>\n<h2>\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a<\/h2>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0438 API \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0430 \u0434\u043b\u044f Blazor WebAssembly. \u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e API \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f Blazor WebAssembly \u0431\u044b\u043b\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b \u0434\u043b\u044f \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0432 ASP.NET Core, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0431\u044b\u043b\u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b. \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 API \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u043e\u0432\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 <i>Program.cs<\/i>:<\/p>\n<pre><code class=\"plaintext\">public class Program {     public static async Task Main(string[] args)     {         var builder = WebAssemblyHostBuilder.CreateDefault(args);         builder.RootComponents.Add&lt;App&gt;(&quot;app&quot;);          await builder.Build().RunAsync();     } }<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Blazor WebAssembly \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 <code>Main<\/code> \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0445\u043e\u0441\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0432\u044b\u0437\u043e\u0432\u0438\u0442\u0435 <code>WebAssemblyHostBuilder.CreateDefault()<\/code>. \u041a\u043e\u0440\u043d\u0435\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a\u0430; \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>Startup<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>WeatherService<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (DI):<\/p>\n<pre><code class=\"plaintext\">public class Program {     public static async Task Main(string[] args)     {         var builder = WebAssemblyHostBuilder.CreateDefault(args);         builder.Services.AddSingleton&lt;WeatherService&gt;();         builder.RootComponents.Add&lt;App&gt;(&quot;app&quot;);          await builder.Build().RunAsync();     } }<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0445\u043e\u0441\u0442 \u0441\u043e\u0437\u0434\u0430\u043d, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u0438\u0437 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 DI \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e:<\/p>\n<pre><code class=\"plaintext\">public class Program {     public static async Task Main(string[] args)     {         var builder = WebAssemblyHostBuilder.CreateDefault(args);         builder.Services.AddSingleton&lt;WeatherService&gt;();         builder.RootComponents.Add&lt;App&gt;(&quot;app&quot;);          var host = builder.Build();          var weatherService = host.Services.GetRequiredService&lt;WeatherService&gt;();         await weatherService.InitializeWeatherAsync();          await host.RunAsync();     } }<\/code><\/pre>\n<p>  \u0425\u043e\u0441\u0442 \u0442\u0430\u043a\u0436\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0435, \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<pre><code class=\"plaintext\">public class Program {     public static async Task Main(string[] args)     {         var builder = WebAssemblyHostBuilder.CreateDefault(args);         builder.Services.AddSingleton&lt;WeatherService&gt;();         builder.RootComponents.Add&lt;App&gt;(&quot;app&quot;);          var host = builder.Build();          var weatherService = host.Services.GetRequiredService&lt;WeatherService&gt;();         await weatherService.InitializeWeatherAsync(host.Configuration[&quot;WeatherServiceUrl&quot;]);          await host.RunAsync();     } } <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/h2>\n<p>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Blazor WebAssembly \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a .NET IL \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0445 \u043e\u0431\u0440\u0435\u0437\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Blazor \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0435\u0437\u0430\u044e\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u2014 \u043e\u043a\u043e\u043b\u043e 100 \u041a\u0411. \u041a\u0430\u043a \u0438 \u0440\u0430\u043d\u044c\u0448\u0435, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043a\u043e\u0433\u0434\u0430-\u043b\u0438\u0431\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0432\u0442\u043e <code>&lt;BlazorLinkOnBuild&gt;false&lt;\/BlazorLinkOnBuild&gt;<\/code>\u00a0\u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u0444\u0430\u043b\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 .NET SignalR<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SignalR \u0438\u0437 \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 Blazor WebAssembly \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 .NET SignalR.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c SignalR \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 Blazor WebAssembly:<\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Blazor WebAssembly, \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 ASP.NET Core.\n<pre><code class=\"plaintext\">dotnet new blazorwasm -ho -o BlazorSignalRApp<\/code><\/pre>\n<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0430\u043a\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 ASP.NET Core SignalR \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 <i>Client<\/i>.\n<pre><code class=\"plaintext\">cd BlazorSignalRApp dotnet add Client package Microsoft.AspNetCore.SignalR.Client<\/code><\/pre>\n<\/li>\n<li>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <i>Server<\/i> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 <i>Hub\/ChatHub.cs<\/i>.\n<pre><code class=\"plaintext\">using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR;  namespace BlazorSignalRApp.Server.Hubs {     public class ChatHub : Hub     {         public async Task SendMessage(string user, string message)         {             await Clients.All.SendAsync(&quot;ReceiveMessage&quot;, user, message);         }     } } <\/code><\/pre>\n<\/li>\n<li>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <i>Server<\/i> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0443\u0436\u0431\u044b SignalR \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Startup.ConfigureServices<\/code>.\n<pre><code class=\"plaintext\">services.AddSignalR(); <\/code><\/pre>\n<\/li>\n<li>\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0434\u043b\u044f <code>ChatHub<\/code> \u0432 <code>Startup.Configure<\/code>.\n<pre><code class=\"plaintext\">.UseEndpoints(endpoints =&gt; {     endpoints.MapDefaultControllerRoute();     endpoints.MapHub&lt;ChatHub&gt;(&quot;\/chatHub&quot;);     endpoints.MapFallbackToClientSideBlazor&lt;Client.Program&gt;(&quot;index.html&quot;); }); <\/code><\/pre>\n<\/li>\n<li>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 <i>Pages\/Index.razor<\/i> \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <i>Client<\/i> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u043e\u0439.\n<pre><code class=\"plaintext\">@using Microsoft.AspNetCore.SignalR.Client @page &quot;\/&quot; @inject NavigationManager NavigationManager  &lt;div&gt;     &lt;label for=&quot;userInput&quot;&gt;User:&lt;\/label&gt;     &lt;input id=&quot;userInput&quot; @bind=&quot;userInput&quot; \/&gt; &lt;\/div&gt; &lt;div class=&quot;form-group&quot;&gt;     &lt;label for=&quot;messageInput&quot;&gt;Message:&lt;\/label&gt;     &lt;input id=&quot;messageInput&quot; @bind=&quot;messageInput&quot; \/&gt; &lt;\/div&gt; &lt;button @onclick=&quot;Send&quot; disabled=&quot;@(!IsConnected)&quot;&gt;Send Message&lt;\/button&gt;  &lt;hr \/&gt;  &lt;ul id=&quot;messagesList&quot;&gt;     @foreach (var message in messages)     {         &lt;li&gt;@message&lt;\/li&gt;     } &lt;\/ul&gt;  @code {     HubConnection hubConnection;     List&lt;string&gt; messages = new List&lt;string&gt;();     string userInput;     string messageInput;      protected override async Task OnInitializedAsync()     {         hubConnection = new HubConnectionBuilder()             .WithUrl(NavigationManager.ToAbsoluteUri(&quot;\/chatHub&quot;))             .Build();          hubConnection.On&lt;string, string&gt;(&quot;ReceiveMessage&quot;, (user, message) =&gt;         {             var encodedMsg = user + &quot; says &quot; + message;             messages.Add(encodedMsg);             StateHasChanged();         });          await hubConnection.StartAsync();     }      Task Send() =&gt; hubConnection.SendAsync(&quot;SendMessage&quot;, userInput, messageInput);      public bool IsConnected =&gt; hubConnection.State == HubConnectionState.Connected; } <\/code><\/pre>\n<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 <i>Server<\/i>\n<pre><code class=\"plaintext\">cd Server dotnet run <\/code><\/pre>\n<\/li>\n<li>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0434\u0432\u0443\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u043a\u043b\u0430\u0434\u043a\u0430\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0447\u0435\u0440\u0435\u0437 SignalR.  <\/li>\n<\/ol>\n<p>  <\/p>\n<h2>\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u044b \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438.<\/p>\n<ul>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Blazor WebAssembly, \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 ASP.NET Core, \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f:\n<pre><code class=\"plaintext\">CSC : warning CS8034: Unable to load Analyzer assembly C:\\Users\\user\\.nuget\\packages\\microsoft.aspnetcore.components.analyzers\\3.1.0\\analyzers\\dotnet\\cs\\Microsoft.AspNetCore.Components.Analyzers.dll : Assembly with same name is already loaded. <\/code><\/pre>\n<ul>\n<li>\u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u00a0<code>&lt;DisableImplicitComponentsAnalyzers&gt;true&lt;\/DisableImplicitComponentsAnalyzers&gt;<\/code>\u00a0MSBuild.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u041e\u0442\u0437\u044b\u0432\u044b<\/h2>\n<p>  \u041c\u044b \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u044d\u0442\u043e\u0439 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Blazor WebAssembly! \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0434\u0430\u0439\u0442\u0435 \u043d\u0430\u043c \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435, \u0441\u043e\u043e\u0431\u0449\u0430\u044f \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445 \u043d\u0430 <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/issues\">GitHub<\/a>.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Blazor.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/microsoft\/blog\/486638\/\"> https:\/\/habr.com\/ru\/company\/microsoft\/blog\/486638\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/microsoft\/blog\/486638\/\">\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Blazor WebAssembly \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0412\u043e\u0442 \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435:<\/p>\n<ul>\n<li>\u0412\u0435\u0440\u0441\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0434\u043e 3.2<\/li>\n<li>\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a<\/li>\n<li>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/li>\n<li>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 .NET SignalR<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ur\/ko\/lb\/urkolb1apkzkcs3kq3wh-t9py7w.jpeg\"><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-298238","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=298238"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298238\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}