Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions Blazor.DownloadFileFast Solution.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
# Visual Studio Version 18
VisualStudioVersion = 18.0.11205.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{33997DC9-84AA-47E3-BEB5-C418065DC503}"
EndProject
Expand Down Expand Up @@ -32,6 +32,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.DownloadFileFast.Exa
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.DownloadFileFast.Example_NET9", "Examples\Blazor.DownloadFileFast.Example_NET9\Blazor.DownloadFileFast.Example_NET9.csproj", "{FCC3D4A3-0A8D-507B-BBEE-5075B6B51E4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.DownloadFileFast.Example_NET10", "Examples\Blazor.DownloadFileFast.Example_NET10\Blazor.DownloadFileFast.Example_NET10.csproj", "{E56D051E-164B-44A6-BB03-55DD70BD73DF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.DownloadFileFast.Example_NET10_Subdirectory.Server", "Examples\Blazor.DownloadFileFast.Example_NET10_Subdirectory.Server\Blazor.DownloadFileFast.Example_NET10_Subdirectory.Server.csproj", "{1A21AC74-76CF-4755-A8BD-419C93220193}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.DownloadFileFast.Example_NET10_Subdirectory.Client", "Examples\Blazor.DownloadFileFast.Example_NET10_Subdirectory.Client\Blazor.DownloadFileFast.Example_NET10_Subdirectory.Client.csproj", "{E8F4365B-7A21-464C-B8CD-D846F1530A8C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -70,6 +76,18 @@ Global
{FCC3D4A3-0A8D-507B-BBEE-5075B6B51E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCC3D4A3-0A8D-507B-BBEE-5075B6B51E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCC3D4A3-0A8D-507B-BBEE-5075B6B51E4E}.Release|Any CPU.Build.0 = Release|Any CPU
{E56D051E-164B-44A6-BB03-55DD70BD73DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E56D051E-164B-44A6-BB03-55DD70BD73DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E56D051E-164B-44A6-BB03-55DD70BD73DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E56D051E-164B-44A6-BB03-55DD70BD73DF}.Release|Any CPU.Build.0 = Release|Any CPU
{1A21AC74-76CF-4755-A8BD-419C93220193}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A21AC74-76CF-4755-A8BD-419C93220193}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A21AC74-76CF-4755-A8BD-419C93220193}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A21AC74-76CF-4755-A8BD-419C93220193}.Release|Any CPU.Build.0 = Release|Any CPU
{E8F4365B-7A21-464C-B8CD-D846F1530A8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8F4365B-7A21-464C-B8CD-D846F1530A8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8F4365B-7A21-464C-B8CD-D846F1530A8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8F4365B-7A21-464C-B8CD-D846F1530A8C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -83,6 +101,9 @@ Global
{5D0E02E3-4BD9-F76C-918C-3D587C02DA96} = {1D3B0899-8261-4023-B62E-F1A70CF0BBD8}
{5C24A50F-F7E9-85D5-23E3-65B2A39DE0E7} = {1D3B0899-8261-4023-B62E-F1A70CF0BBD8}
{FCC3D4A3-0A8D-507B-BBEE-5075B6B51E4E} = {1D3B0899-8261-4023-B62E-F1A70CF0BBD8}
{E56D051E-164B-44A6-BB03-55DD70BD73DF} = {1D3B0899-8261-4023-B62E-F1A70CF0BBD8}
{1A21AC74-76CF-4755-A8BD-419C93220193} = {1D3B0899-8261-4023-B62E-F1A70CF0BBD8}
{E8F4365B-7A21-464C-B8CD-D846F1530A8C} = {1D3B0899-8261-4023-B62E-F1A70CF0BBD8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {95736335-0C8B-4FDA-8722-E08046339B83}
Expand Down
4 changes: 4 additions & 0 deletions Blazor.DownloadFileFast/Blazor.DownloadFileFast.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.JSInterop" Version="9.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
<PackageReference Include="Microsoft.JSInterop" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
<None Remove="JavaScript\download.js" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public BlazorDownloadFileService(IJSRuntime js)
if (BlazorUtils.IsWASM)
{
#pragma warning disable CA1416
Task.Run(async () => await JSHost.ImportAsync("download.js", "/_content/BlazorDownloadFileFast/download7up.js"));
Task.Run(async () => await JSHost.ImportAsync("download.js", "../_content/BlazorDownloadFileFast/download7up.js"));
#pragma warning restore CA1416
return;
}
Expand Down
6 changes: 6 additions & 0 deletions Examples/Blazor.DownloadFileFast.Example_NET10/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Router AppAssembly="@typeof(App).Assembly" NotFoundPage="typeof(Pages.NotFound)">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
</Router>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OverrideHtmlAssetPlaceholders>true</OverrideHtmlAssetPlaceholders>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.18" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Blazor.DownloadFileFast\Blazor.DownloadFileFast.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@inherits LayoutComponentBase
<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>

<article class="content px-4">
@Body
</article>
</main>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}

.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}

.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row {
justify-content: space-between;
}

.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}

.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">Blazor.DownloadFileFast.Example_NET10</a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>

<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
<nav class="nav flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>
</nav>
</div>

@code {
private bool collapseNavMenu = true;

private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;

private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}

.top-row {
min-height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}

.navbar-brand {
font-size: 1.1rem;
}

.bi {
display: inline-block;
position: relative;
width: 1.25rem;
height: 1.25rem;
margin-right: 0.75rem;
top: -1px;
background-size: cover;
}

.bi-house-door-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
}

.bi-plus-square-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
}

.bi-list-nested-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}

.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}

.nav-item:first-of-type {
padding-top: 1rem;
}

.nav-item:last-of-type {
padding-bottom: 1rem;
}

.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}

.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.37);
color: white;
}

.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}

@media (min-width: 641px) {
.navbar-toggler {
display: none;
}

.collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}

.nav-scrollable {
/* Allow sidebar to scroll for tall menus */
height: calc(100vh - 3.5rem);
overflow-y: auto;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@page "/"

<PageTitle>Home</PageTitle>

<input class="btn btn-primary" @onclick="@DownloadFileAsync" value="Download" />
22 changes: 22 additions & 0 deletions Examples/Blazor.DownloadFileFast.Example_NET10/Pages/Home.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Blazor.DownloadFileFast.Interfaces;
using Microsoft.AspNetCore.Components;
using RandomDataGenerator.FieldOptions;
using RandomDataGenerator.Randomizers;
using System.Text;

namespace Blazor.DownloadFileFast.Example_NET10.Pages;

public partial class Home
{
[Inject]
public IBlazorDownloadFileService BlazorDownloadFileService { get; set; } = null!;

private readonly IRandomizerString _random = RandomizerFactory.GetRandomizer(new FieldOptionsTextLipsum { Paragraphs = 10 });

public async Task DownloadFileAsync()
{
var bytes = Encoding.ASCII.GetBytes(_random.Generate()!);

await BlazorDownloadFileService.DownloadFileAsync("example.txt", bytes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@page "/not-found"
@layout MainLayout

<h3>Not Found</h3>
<p>Sorry, the content you are looking for does not exist.</p>
12 changes: 12 additions & 0 deletions Examples/Blazor.DownloadFileFast.Example_NET10/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Blazor.DownloadFileFast.Example_NET10;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddBlazorDownloadFile();

await builder.Build().RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5171",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7253;http://localhost:5171",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
10 changes: 10 additions & 0 deletions Examples/Blazor.DownloadFileFast.Example_NET10/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using Blazor.DownloadFileFast.Example_NET10
@using Blazor.DownloadFileFast.Example_NET10.Layout
Loading