{"id":18246673,"url":"https://github.com/datvm/demoblazorinsideweb","last_synced_at":"2026-01-21T20:38:26.166Z","repository":{"id":143659159,"uuid":"611656193","full_name":"datvm/DemoBlazorInsideWeb","owner":"datvm","description":"This is a demo to add Blazor Assembly inside an existing ASP.NET Core website. Here Blazor simply acts as a Web App content inside a Web Page.","archived":false,"fork":false,"pushed_at":"2023-03-09T14:19:21.000Z","size":1025,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T19:33:58.035Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datvm.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-03-09T09:21:06.000Z","updated_at":"2023-03-09T09:21:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"66165d4b-8ef4-45c4-86fd-e9e1ab67ee54","html_url":"https://github.com/datvm/DemoBlazorInsideWeb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/datvm/DemoBlazorInsideWeb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FDemoBlazorInsideWeb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FDemoBlazorInsideWeb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FDemoBlazorInsideWeb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FDemoBlazorInsideWeb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datvm","download_url":"https://codeload.github.com/datvm/DemoBlazorInsideWeb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datvm%2FDemoBlazorInsideWeb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28642220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T18:04:35.752Z","status":"ssl_error","status_checked_at":"2026-01-21T18:03:55.054Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-05T09:27:14.163Z","updated_at":"2026-01-21T20:38:23.221Z","avatar_url":"https://github.com/datvm.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nThis repo is to solve my problem with the the following scenario:\n\n- I already have an ASP.NET Core website (project A) https://www.example.com with many pages.\n\n- I now want to add a page like Feature.cshtml at https://www.example.com/feature, which use Blazor (project B) has content like this:\n\n```\n\u003c!-- Other content: header, texts, etc --\u003e\n\n\u003cdiv id=\"app\"\u003e\n    Blazor app here\n\u003c/div\u003e\n\n\u003c!-- Other content: more text, footer, scripts, etc --\u003e\n```\n\nThe final result looks like this:\n\n![Demo UI](./img/demo-ui.jpg)\n\nYou can see the steps in this repo:\n\n- At commit #2be15e3, I have an ASP.NET Core website (just a starting template). Consider this your existing website.\n\n- [Commit #ba13eaf to 8bdae3a](https://github.com/datvm/DemoBlazorInsideWeb/compare/2be15e3e54972946b0c03aa5b18024c892066b23..8bdae3a24e9362030313495fe403907c968ac624?diff=split) adds a Blazor app to the website. You can see the changes in the commit.\n\n# Step-by-step guide\n\n## 1. Setup a new Blazor WebAssembly App (B)\n\n- Create a new `Blazor WebAssembly App` project, for example `DemoBlazorInsideWeb.BlazorApp`.\n\n- Update your router in `App.razor` to show the `Index` page for all routes:\n\n```html\n\u003cRouter AppAssembly=\"@typeof(App).Assembly\"\u003e\n    \u003cFound Context=\"routeData\"\u003e\n        \u003c!-- Delete everything here --\u003e\n    \u003c/Found\u003e\n    \u003cNotFound\u003e\n        \u003c!-- Add this here --\u003e\n        \u003cLayoutView Layout=\"@typeof(MainLayout)\"\u003e\n            \u003cIndex /\u003e\n        \u003c/LayoutView\u003e\n    \u003c/NotFound\u003e\n\u003c/Router\u003e\n```\n\n- Optionally delete `@page` in your `Index.razor` file so no URL can ever be routed to it. This is to prevent a route accidentally match it.\n\n- Optionally delete `index.html` file in your `wwwroot` folder. However you may want to keep the content somewhere to copy its content later.\n\n\u003e **Note**  \n\u003e You can still use Routing if you want to serve multiple apps on the same website (even though you have to pack all those apps inside this single project)\n\n## 2. Setup your (existing) ASP.NET Core website (A)\n\n- Add the Blazor project as Reference to your ASP.NET Core website project (A refers to or depends on B).\n\n- Install `Microsoft.AspNetCore.Components.WebAssembly.Server` Nuget package:\n\n```ps\ndotnet add package Microsoft.AspNetCore.Components.WebAssembly.Server\n```\n\n- In your app startup (`Program.cs` or `Startup.cs`), add `app.UseBlazorFrameworkFiles()` before `app.UseStaticFiles()`:\n\n```cs\napp.UseBlazorFrameworkFiles();\napp.UseStaticFiles();\n```\n\n- In order to debug WASM app, you need to:\n\n  - Add `app.UseWebAssemblyDebugging();` in Development environment:\n\n    ```cs\n    if (!app.Environment.IsDevelopment())\n    {\n        // Usually the template has this block\n    }\n    else // And you add this block\n    {\n        app.UseWebAssemblyDebugging();\n    }\n    ```\n\n  - Add `inspectUri` property to your `launchSettings.json` file (you should find it in `Properties` folder). Add it to whichever profile you use, `https` and/or `IIS Express`:\n\n    ```json\n    {\n        // ...\n        \"IIS Express\": {\n            // ...\n            \"inspectUri\": \"{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}\"\n        }\n    }\n    ```\n\n## 3. Setup the new web (Feature) page\n\nIn the ASP.NET Core Razor Page that you want to add the Blazor app, you need to setup Blazor's content\n\n- Add the HTML and Javascript content:\n\n```html\n\u003c!-- Other Razor code --\u003e\n\n\u003cdiv id=\"app\"\u003e\n    \u003c!-- Loading content before Blazor loads. You can copy it from index.html file --\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"blazor-error-ui\"\u003e\n    An unhandled error has occurred.\n    \u003ca href=\"\" class=\"reload\"\u003eReload\u003c/a\u003e\n    \u003ca class=\"dismiss\"\u003e🗙\u003c/a\u003e\n\u003c/div\u003e\n\n\u003c!-- Other Razor code --\u003e\n\n\u003c!-- Add the script where relevant to your project --\u003e\n\u003cscript src=\"_framework/blazor.webassembly.js\"\u003e\u003c/script\u003e\n```\n\n- You should also refer to the Blazor's CSS file, or simply move its content to your own ASP.NET Core project:\n\n```html\n\u003c!-- You need to have Heads section in your Layout --\u003e\n@section Heads {\n    \u003clink rel=\"stylesheet\" href=\"~/css/app.css\" /\u003e\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatvm%2Fdemoblazorinsideweb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatvm%2Fdemoblazorinsideweb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatvm%2Fdemoblazorinsideweb/lists"}