Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor WebAssembly app in old ASP.NET project #1

Open
wants to merge 1 commit into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,6 +1,7 @@
bin/
obj/
/packages/
.idea/
.vs/
*.user
/packages/
.idea/
/OldAspNetApp/_framework/**
.vs/
*.user
@@ -0,0 +1,8 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData"/>
</Found>
<NotFound>
<p>Sorry, there's nothing at this address.</p>
</NotFound>
</Router>
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview9.19465.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview9.19465.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview9.19465.2" />
<Content Update="web.config">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<Target Name="CopyToOldAspNetApp" AfterTargets="Build">
<Exec Command="xcopy $(TargetDir)web.config $(TargetDir)dist\_framework\ /Y" />
<Exec Command="xcopy $(TargetDir)dist $(SolutionDir)OldAspNetApp /Y /S" />
</Target>

</Project>
@@ -0,0 +1,20 @@
@page "/Home/About"

<div class="panel panel-primary">
<div class="panel-heading">
Blazor WASM app
</div>
<div class="panel-body">
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
</div>
</div>

@code {
int currentCount = 0;

void IncrementCount()
{
currentCount++;
}
}
@@ -0,0 +1,20 @@
@page "/Home/Contact"

<div class="panel panel-warning">
<div class="panel-heading">
Blazor WASM app
</div>
<div class="panel-body">
<p>Current count: @currentCount</p>
<button class="btn btn-warning" @onclick="IncrementCount">Click me</button>
</div>
</div>

@code {
int currentCount = 0;

void IncrementCount()
{
currentCount++;
}
}
@@ -0,0 +1,20 @@
@page "/"

<div class="panel panel-success">
<div class="panel-heading">
Blazor WASM app
</div>
<div class="panel-body">
<p>Current count: @currentCount</p>
<button class="btn btn-success" @onclick="IncrementCount">Click me</button>
</div>
</div>

@code {
int currentCount = 0;

void IncrementCount()
{
currentCount++;
}
}
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Blazor.Hosting;

namespace BlazorWasmApp
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) =>
BlazorWebAssemblyHost.CreateDefaultBuilder()
.UseBlazorStartup<Startup>();
}
}
@@ -0,0 +1,25 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Builder;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.Extensions.DependencyInjection;

namespace BlazorWasmApp
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<INavigationInterception>(new DisabledNavigationInterception());
}

public void Configure(IComponentsApplicationBuilder app)
{
app.AddComponent<App>("BlazorWasmApp");
}

public class DisabledNavigationInterception : INavigationInterception
{
public Task EnableNavigationInterceptionAsync() => Task.CompletedTask;
}
}
}
@@ -0,0 +1,5 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@@ -0,0 +1,29 @@
<configuration>
<system.webServer>
<handlers>
<clear />
<add
name="StaticFile"
path="*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
resourceType="Either"
requireAccess="Read" />
</handlers>
<staticContent>
<remove fileExtension=".dll" />
<remove fileExtension=".json" />
<remove fileExtension=".wasm" />
<remove fileExtension=".pdb" />
<mimeMap fileExtension=".dll" mimeType="application/octet-stream" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
<mimeMap fileExtension=".pdb" mimeType="text/plain" />
</staticContent>
<httpProtocol>
<customHeaders>
<!-- https://github.com/SteveSandersonMS/BlazorMigration/commit/a82fd5099ea0d690c7709bd1217230046f576530 -->
<add name="Cache-Control" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
@@ -2,6 +2,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OldAspNetApp", "OldAspNetApp\OldAspNetApp.csproj", "{6856E24E-42F3-4D6C-A177-B3AF7FF67D1E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWasmApp", "BlazorWasmApp\BlazorWasmApp.csproj", "{CEAC856F-6F18-4FDA-91C8-838380946527}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -12,5 +14,9 @@ Global
{6856E24E-42F3-4D6C-A177-B3AF7FF67D1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6856E24E-42F3-4D6C-A177-B3AF7FF67D1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6856E24E-42F3-4D6C-A177-B3AF7FF67D1E}.Release|Any CPU.Build.0 = Release|Any CPU
{CEAC856F-6F18-4FDA-91C8-838380946527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEAC856F-6F18-4FDA-91C8-838380946527}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEAC856F-6F18-4FDA-91C8-838380946527}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEAC856F-6F18-4FDA-91C8-838380946527}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
@@ -155,6 +155,7 @@
<Content Include="Views\_ViewStart.cshtml"/>
<Content Include="Views\Shared\Error.cshtml"/>
<Content Include="Views\Shared\_Layout.cshtml"/>
<Content Include="Views\Shared\BlazorWasmApp.cshtml" />
<Content Include="Views\Home\About.cshtml"/>
<Content Include="Views\Home\Contact.cshtml"/>
<Content Include="Views\Home\Index.cshtml"/>
@@ -1,6 +1,9 @@
@{
ViewBag.Title = "About";
}

@Html.Partial("BlazorWasmApp")

<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>

@@ -1,6 +1,9 @@
@{
ViewBag.Title = "Contact";
}

@Html.Partial("BlazorWasmApp")

<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>

@@ -2,6 +2,8 @@
ViewBag.Title = "Home Page";
}

@Html.Partial("BlazorWasmApp")

<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
@@ -0,0 +1,3 @@
<BlazorWasmApp>Blazor WASM app loading...</BlazorWasmApp>
<base href="/"/>
<script src="/_framework/blazor.webassembly.js"></script>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.