対象èªè
ãC#ã¨Webã·ã¹ãã ã®åºç¤çãªç¥èãããæ¹ã対象ã¨ãã¾ããC#ã®åºæ¬ææ³ãªã©ã®è§£èª¬ã¯å²æãã¾ãã
ã¯ããã«
ãBlazor WebAssemblyã¯ãC#è¨èªãç¨ãã¦ãWebãã©ã¦ã¶ä¸ã§å®è¡å¯è½ãªWebã¢ããªã±ã¼ã·ã§ã³ãæ§ç¯ããããã®ãã¬ã¼ã ã¯ã¼ã¯ã§ãããã®ãã¬ã¼ã ã¯ã¼ã¯ã使ãã°ãC#è¨èªã使ã£ã¦SPAï¼Single Page Applicationï¼ãå®ç¾ãããã¨ãã§ãã¾ããSPAã¨ã¯ãåä¸ã®Webãã¼ã¸ã§åä½ããWebã¢ããªã±ã¼ã·ã§ã³ã®ãã¨ã§ãããã¼ã¸é·ç§»ãè¡ãããå¿ è¦ã«å¿ãã¦ã³ã³ãã³ãã®æ¸ãæããè¡ãããããã¹ã¯ãããã¢ããªã®ããã«è»½å¿«ãªæä½ãè¡ããã®ãç¹å¾´ã§ããä¸è¬çãªWebã¢ããªã¼ã±ã¼ã·ã§ã³ã§ã¯ãSPAã¯JavaScriptãç¨ãã¦å®è£ ãã¾ãã
ãæ¬é£è¼ã§ã¯ããããããªWebã¢ããªãä½æããªããããã®Blazor WebAssemblyã«ã¤ãã¦è§£èª¬ãã¾ããä»åã¯ãBlazorã®æ¦è¦ã¨éçºç°å¢ã®èª¬æãããã¦ãã©ã¦ã¶ã§ãHello,world!ãã¨è¡¨ç¤ºããã¢ããªã±ã¼ã·ã§ã³ãä½æãã¾ãã
Blazorã¨ã¯
ãæåã«ãASP.NETããããããã¦ããã¾ãããã
ãå½åã®ASP.NETã¯ãWindowsæ¨æºã®.NET Frameworkã¨å¼ã°ããã¢ããªã±ã¼ã·ã§ã³éçºã»å®è¡ç°å¢ã§åä½ãããWebã¢ããªã±ã¼ã·ã§ã³ç¨ãã¬ã¼ã ã¯ã¼ã¯ã§ãããã¾ããASP.NETãåºç¤ã¨ãã¦ãHTMLãHTTPéä¿¡ãªã©ã®å¦çãæ½è±¡åãã¦ãã¹ã¯ãããã¢ããªã®ãããªæè¦ã§Webã·ã¹ãã ãæ§ç¯ã§ããWebãã©ã¼ã ãã¯ããã次ã®ãããªã©ã¤ãã©ãªããã¬ã¼ã ã¯ã¼ã¯ãæä¾ããã¦ãã¾ããã
å称 | æ¦è¦ |
---|---|
ASP.NET Webãã©ã¼ã | Visual Studioã§éçºã§ããWebã·ã¹ãã ãã¬ã¼ã ã¯ã¼ã¯ |
ASP.NET MVC | MVCãã¿ã¼ã³ã®Webã·ã¹ãã ãæ§ç¯ã§ãããã¬ã¼ã ã¯ã¼ã¯ |
ASP.NET Webãã¼ã¸ | HTMLãåçã«çæããããã®Razorãã¥ã¼ã»ã¨ã³ã¸ã³ |
ASP.NET Web API | RESTfulãªWeb APIä½æã«ç¹åããã©ã¤ãã©ãª |
ASP.NET SignalR | ãªã¢ã«ã¿ã¤ã å¦çç¨éä¿¡ã©ã¤ãã©ãª |
ããã®å¾ãã¤ã¯ãã½ããã¯ãWindowsç°å¢ã«ä¾åãã.NETæ¦ç¥ãè¦ç´ããLinuxãmacOSã§ãåä½ãããã¯ãã¹ãã©ãããã©ã¼ã ãã¤ãªã¼ãã³ã½ã¼ã¹ã®ãASP.NET Coreãããªãªã¼ã¹ãã¾ããã
ç°å¢ã»æ©è½ | æ¦è¦ |
---|---|
対å¿OS | WindowsãmacOSãLinux |
å©ç¨è¨èª | C#ãF# |
ç¶ç¶æ©è½ | MVCãSignalRãWeb API |
æ°æ©è½ | Razor PagesãBlazor |
Webãµã¼ãã¼ | IISãNginxãApacheãªã© |
ãASP.NET Coreã¯ãASP.NET 4.xããã¼ã¹ã«ãã¦ãã¾ãããWebãã©ã¼ã ã«ã¯å¯¾å¿ãã¦ãã¾ãããã¾ããéçºè¨èªã«Visual Basicãå©ç¨ã§ããªããªãã¾ããã
ãä¸æ¹ãASP.NET Coreã«ãªã£ã¦ãæ°ããªã©ã¤ãã©ãªããã¬ã¼ã ã¯ã¼ã¯ãæä¾ããã¦ãã¾ããRazor Pagesã¯ãASP.NET Core 2.0ããå©ç¨ã§ããæ©è½ã§ãMVVMãã¿ã¼ã³ã®Webã¢ããªã±ã¼ã·ã§ã³ãå®ç¾ã§ãããã¬ã¼ã ã¯ã¼ã¯ã§ãã
ãRazor Pagesã§ã¯ãViewã«ãããé¨åã¯Razoræ§æã«ããcshtmlãã¡ã¤ã«ï¼HTMLãæ¡å¼µãã¦ãC#ã³ã¼ããªã©ãå«ãããã¨ãã§ããï¼ã«ãViewModelã¯ãã®cshtmlããçæãããC#ã®ã¯ã©ã¹ã«ãªã£ã¦ãã¾ãããã®ãããã®æ§é ã¯ããã®å¾ã«ãªãªã¼ã¹ããããBlazorãã¬ã¼ã ã¯ã¼ã¯ã§ãåæ§ã¨ãªã£ã¦ãã¾ãã
ãBlazorã¯ãé常JavaScirptã使ç¨ããWebãã©ã¦ã¶ã§ã®ããã³ãã¨ã³ãã®å¦çããC#ã使ã£ã¦è¨è¿°ã§ãããã¬ã¼ã ã¯ã¼ã¯ã§ããããã¾ã§ã®ASP.NETã¯ããã¹ã¦ãµã¼ãã¼ãµã¤ãã§å®è¡ãããå¦çã«ç¨ãããã®ã§ãããBlazorã使ãã°ããµã¼ãã¼ãµã¤ãã ãã§ãªããã¯ã©ã¤ã¢ã³ããå«ããå ¨ä½ããC#ã使ã£ã¦éçºãããã¨ãå¯è½ã«ãªãã¾ãï¼ãã¡ãããæ¢åã®JavaScirptã¨ãä½µç¨ã§ãã¾ãï¼ã
Blazor WebAssemblyã¨Blazor Server
ãBlazorã«ã¯ããµã¼ãã¼ãµã¤ãã§åä½ããBlazor Serverã¨ããã©ã¦ã¶ä¸ã§åä½ããBlazor WebAssemblyã®2ã¤ã®ã¢ãã«ãããã¾ãã
ãBlazor Serverã§ã¯ããµã¼ãã¼ä¸ã®.NET Coreç°å¢ã§ä¸»ãªå¦çãè¡ããããµã¼ãã¼å´ã®ã³ã¼ãã§ããã©ã¦ã¶ã¼ã®ã³ã³ãã³ãï¼DOMï¼ãæ¸ãæããå½¢ã¨ãªãã¾ãããµã¼ãã¼ã¨ãã©ã¦ã¶éã®ããã¨ãã«ã¯ãASP.NET Core SignalRã¨å¼ã°ããã©ã¤ãã©ãªãç¨ãããã¾ãã
ãä¸æ¹ãBlazor WebAssemblyã¯ãWebAssemblyãå©ç¨ãã¦ããã©ã¦ã¶ã¼å ã§.NETã³ã¼ããå®è¡ãããã®ã§ããWebAssemblyã¨ã¯ããã©ã¦ã¶ä¸ã§ãã¤ããªã³ã¼ããå®è¡ã§ããããã«ããæè¡ã®ãã¨ã§ããå¥éãã©ã°ã¤ã³ãå¿ è¦ãªãããã©ã¦ã¶èªä½ã§ãµãã¼ãããã¦ãã¾ãï¼Microsoft Internet Explorerã¯æªå¯¾å¿ï¼ã
ãBlazor WebAssemblyã§ã¯ãæåã«ã.NETã¢ã»ã³ããªã¨ã©ã³ã¿ã¤ã ããã©ã¦ã¶ã«ãã¦ã³ãã¼ãããããã®å¾ãã©ã¦ã¶ä¸ã§ã.NETã¢ã»ã³ããªãå®è¡ããã¾ããWebAssemblyã®ã»ãã¥ãªãã£ã®å¶éã®ãããç´æ¥ãã¡ã¤ã«ãéãã¦å®è¡ãããã¨ã¯ã§ãã¾ãããã¾ãããã¡ã¤ã«ãµã¤ãºã大ãããªãã¾ãã®ã§ãæåã®ãã¦ã³ãã¼ãã«æéããããã¾ãããã ããã®å¾ã¯ããã¹ã¯ãããã¢ããªåæ§ã«ãã³ã¼ããå®è¡ããããã¨ã«ãªãã¾ãã
ãBlazor Serverã¯ãé常ã®Webã·ã¹ãã ã¨åæ§ãWebãµã¼ãã¼ã¨ãã©ã¦ã¶ã¨ã®å¸¸ææ¥ç¶ãå¿ é ã§ããµã¼ãã¼ç°å¢ã«ã¯ã.NET Coreã®å®è¡ç°å¢ãå¿ è¦ã§ããBlazor WebAssemblyã§ããã°ããµã¼ãã¼å´ã®ç°å¢ãå¦çãæèãããã¨ãªãããµã¼ãã¼ã¬ã¹ãã¤ãã©ã¦ã¶ã§åä½ããåçãªWebã¢ããªã±ã¼ã·ã§ã³ã®éçºãå¯è½ã§ãã
ãBlazor WebAssemblyã¯ãWebã¢ããªã±ã¼ã·ã§ã³ã§ãããããå½ç¶ãã©ã¦ã¶ã®æ©è½ããå©ç¨ã§ãã¾ãããããããããã·ã³ãã«ãªæ§æã§ãã¹ã¯ãããã¢ããªã®ãããªWebã¢ããªã±ã¼ã·ã§ã³ãéçºå¯è½ã§ããæ¬é£è¼ã§ã¯ãæ軽ã«ãµã¼ãã¼ã¬ã¹ã§éçºã§ããBlazor WebAssemblyã解説ãããã¨ã«ãã¾ãã
ãnoteãWebAssembly
ãWebAssemblyã¨ã¯ããã©ã¦ã¶ä¸ã§ãã¤ããªã³ã¼ãï¼æ©æ¢°èªï¼ãå®è¡ããæè¡ã®ãã¨ã§ããJavaScriptã§ã¯å®ç¾ã§ããªãå¦çããããé«éãªå®è¡ãç®æãããã«ææ¡ãããMozillaãGoogleãMicrosoftãAppleã®åæã®ãã¨ãWebãã©ã¦ã¶ã®æ¨æºãã©ã¼ãããã¨ãã¦éçºããã¦ãã¾ãã2019å¹´ã«ã¯ãWebæ¨æºã¨ãã¦èªå®ããã¦ãã¾ãã
ãJavaScriptã¯ãå½åHTMLã§ã¯ãã®è¶³ããªãé¨åãè£ãç¨åº¦ã§å©ç¨ããã¦ãã¾ããããããç¾å¨ã§ã¯ãç»åå¦çãªã©ã®ãã«ãã¡ãã£ã¢ãªå¦çãã¯ããããã©ã¦ã¶ã®GUIå¦çã«ã¯ä¸å¯æ¬ ãªæè¡ã¨ãªã£ã¦ãã¾ãããã JavaScriptã¯ã¤ã³ã¿ããªã¿è¨èªã§ãããå¦çã«ããæéãããããªã©ãåä¸è¶³ã¨ãªã£ã¦ãããã¨ãããããé«éã«å®è¡ã§ããæè¡ã¨ãã¦ãWebAssemblyãéçºããã¾ããã