{"id":31282302,"url":"https://github.com/forestbrook/blazorwebassemblyaspnethosted","last_synced_at":"2026-05-16T09:35:25.756Z","repository":{"id":313419804,"uuid":"1051356878","full_name":"Forestbrook/BlazorWebAssemblyAspNetHosted","owner":"Forestbrook","description":"Blazor WebAssembly ASP.NET Core hosted for .NET 9 example","archived":false,"fork":false,"pushed_at":"2025-09-05T22:09:10.000Z","size":734,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-05T23:38:39.332Z","etag":null,"topics":["blazor","blazor-webassembly"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Forestbrook.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-05T21:06:32.000Z","updated_at":"2025-09-05T22:09:13.000Z","dependencies_parsed_at":"2025-09-05T23:48:46.243Z","dependency_job_id":null,"html_url":"https://github.com/Forestbrook/BlazorWebAssemblyAspNetHosted","commit_stats":null,"previous_names":["forestbrook/blazorwebassemblyaspnethosted"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Forestbrook/BlazorWebAssemblyAspNetHosted","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forestbrook%2FBlazorWebAssemblyAspNetHosted","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forestbrook%2FBlazorWebAssemblyAspNetHosted/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forestbrook%2FBlazorWebAssemblyAspNetHosted/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forestbrook%2FBlazorWebAssemblyAspNetHosted/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Forestbrook","download_url":"https://codeload.github.com/Forestbrook/BlazorWebAssemblyAspNetHosted/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forestbrook%2FBlazorWebAssemblyAspNetHosted/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276689013,"owners_count":25686611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","blazor-webassembly"],"created_at":"2025-09-24T03:53:38.885Z","updated_at":"2025-09-24T03:53:42.650Z","avatar_url":"https://github.com/Forestbrook.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blazor WebAssembly ASP.NET Core hosted for .NET 9 example\r\n\r\nThis is the example project as descibed in this [Knowledge Base article](https://www.forestbrook.net/docs/blazor/create-project.html)\r\n\r\nPreviously, Visual Studio had a template to create an ASP.NET Core hosted Blazor WebAssembly solution.\r\nUnfortunately, this project template is not available anymore, except for an old teplate which sticks to .NET 7 (Blazor WebAssembly App Empty)\r\n\r\nThis example is created as described below (and I also made sure the Weather forcast is read from the server).\r\n\r\n## This way you can easily create a Blazor WebAssembly ASP.NET Core hosted solution for .NET 9:\r\n\r\n1. Use the Visual Studio template **Blazor WebAssembly Standalone App**, select **.NET 9** and name the project (here: **BlazorExample.Client**).\r\n2. Add a new project to the solution using the template **ASP.NET Core Web API**, select **.NET 9** and **Use controllers** and name the project (here: **BlazorExample.Server**)\r\n3. Add Nuget package to the server project: **Microsoft.AspNetCore.Components.WebAssembly.Server**\r\n4. Add a **reference** in the server project to the client project\r\n\r\n5. In the server project edit **Program.cs** and add the lines between the lines:\r\n```cs\r\npublic static void Main(string[] args)\r\n{\r\n    var builder = WebApplication.CreateBuilder(args);\r\n    builder.Services.AddControllers();\r\n\r\n    // TODO: Add your own services.\r\n\r\n    var app = builder.Build();\r\n\r\n    // ADD ------------------------------------\r\n    if (app.Environment.IsDevelopment())\r\n        app.UseWebAssemblyDebugging();\r\n    // ------------------------------------\r\n\r\n    app.UseHttpsRedirection();\r\n\r\n    // ADD ------------------------------------\r\n    app.UseBlazorFrameworkFiles();\r\n    app.UseStaticFiles();\r\n    app.UseRouting();\r\n    // ------------------------------------\r\n\r\n    app.UseAuthorization();\r\n\r\n    app.MapControllers();\r\n\r\n    // ADD ------------------------------------\r\n    app.MapFallbackToFile(\"index.html\");\r\n    // ------------------------------------\r\n\r\n    app.Run();\r\n}\r\n```\r\n\r\n6. In the server project change Properties/**launchSettings.json** (you can use other port numbers if you like):\r\n\r\n```json\r\n{\r\n  \"profiles\": {\r\n    \"http\": {\r\n      \"commandName\": \"Project\",\r\n      \"launchBrowser\": true,\r\n      \"environmentVariables\": {\r\n        \"ASPNETCORE_ENVIRONMENT\": \"Development\"\r\n      },\r\n      \"dotnetRunMessages\": true,\r\n      \"inspectUri\": \"{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}\",\r\n      \"applicationUrl\": \"http://localhost:5225\"\r\n    },\r\n    \"https\": {\r\n      \"commandName\": \"Project\",\r\n      \"launchBrowser\": true,\r\n      \"environmentVariables\": {\r\n        \"ASPNETCORE_ENVIRONMENT\": \"Development\"\r\n      },\r\n      \"dotnetRunMessages\": true,\r\n      \"inspectUri\": \"{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}\",\r\n      \"applicationUrl\": \"https://localhost:7283;http://localhost:5225\"\r\n    },\r\n    \"IIS Express\": {\r\n      \"commandName\": \"IISExpress\",\r\n      \"launchBrowser\": true,\r\n      \"environmentVariables\": {\r\n        \"ASPNETCORE_ENVIRONMENT\": \"Development\"\r\n      },\r\n      \"inspectUri\": \"{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}\"\r\n    }\r\n  },\r\n  \"iisExpress\": {\r\n    \"applicationUrl\": \"http://localhost:26936\",\r\n    \"sslPort\": 44351\r\n  },\r\n  \"iisSettings\": {\r\n    \"windowsAuthentication\": false,\r\n    \"anonymousAuthentication\": true,\r\n    \"iisExpress\": {\r\n      \"applicationUrl\": \"http://localhost:65397/\",\r\n      \"sslPort\": 44373\r\n    }\r\n  }\r\n}\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforestbrook%2Fblazorwebassemblyaspnethosted","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforestbrook%2Fblazorwebassemblyaspnethosted","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforestbrook%2Fblazorwebassemblyaspnethosted/lists"}