Skip to content

Commit 87e0b29

Browse files
committed
Added template project
1 parent 440e2fd commit 87e0b29

26 files changed

+5021
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This file explains how Visual Studio created the project.
2+
3+
The following steps were used to generate this project:
4+
- Create new ASP\.NET Core Web API project.
5+
- Update `launchSettings.json` to register the SPA proxy as a startup assembly.
6+
- Update project file to add a reference to the frontend project and set SPA properties.
7+
- Add project to the startup projects list.
8+
- Write this file.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace JMayer.Example.ASPReact.Server.Controllers
4+
{
5+
[ApiController]
6+
[Route("[controller]")]
7+
public class WeatherForecastController : ControllerBase
8+
{
9+
private static readonly string[] Summaries = new[]
10+
{
11+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12+
};
13+
14+
private readonly ILogger<WeatherForecastController> _logger;
15+
16+
public WeatherForecastController(ILogger<WeatherForecastController> logger)
17+
{
18+
_logger = logger;
19+
}
20+
21+
[HttpGet(Name = "GetWeatherForecast")]
22+
public IEnumerable<WeatherForecast> Get()
23+
{
24+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
25+
{
26+
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
27+
TemperatureC = Random.Shared.Next(-20, 55),
28+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
29+
})
30+
.ToArray();
31+
}
32+
}
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<SpaRoot>..\jmayer.example.aspreact.client</SpaRoot>
8+
<SpaProxyLaunchCommand>npm run dev</SpaProxyLaunchCommand>
9+
<SpaProxyServerUrl>https://localhost:5173</SpaProxyServerUrl>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
14+
<Version>8.*-*</Version>
15+
</PackageReference>
16+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\jmayer.example.aspreact.client\jmayer.example.aspreact.client.esproj">
21+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
22+
</ProjectReference>
23+
</ItemGroup>
24+
25+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@JMayer.Example.ASPReact.Server_HostAddress = http://localhost:5264
2+
3+
GET {{JMayer.Example.ASPReact.Server_HostAddress}}/weatherforecast/
4+
Accept: application/json
5+
6+
###
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
5+
builder.Services.AddControllers();
6+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
7+
builder.Services.AddEndpointsApiExplorer();
8+
builder.Services.AddSwaggerGen();
9+
10+
var app = builder.Build();
11+
12+
app.UseDefaultFiles();
13+
app.UseStaticFiles();
14+
15+
// Configure the HTTP request pipeline.
16+
if (app.Environment.IsDevelopment())
17+
{
18+
app.UseSwagger();
19+
app.UseSwaggerUI();
20+
}
21+
22+
app.UseHttpsRedirection();
23+
24+
app.UseAuthorization();
25+
26+
app.MapControllers();
27+
28+
app.MapFallbackToFile("/index.html");
29+
30+
app.Run();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:33551",
8+
"sslPort": 44391
9+
}
10+
},
11+
"profiles": {
12+
"http": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"launchUrl": "swagger",
17+
"applicationUrl": "http://localhost:5264",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development",
20+
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
21+
}
22+
},
23+
"https": {
24+
"commandName": "Project",
25+
"dotnetRunMessages": true,
26+
"launchBrowser": true,
27+
"launchUrl": "swagger",
28+
"applicationUrl": "https://localhost:7020;http://localhost:5264",
29+
"environmentVariables": {
30+
"ASPNETCORE_ENVIRONMENT": "Development",
31+
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
32+
}
33+
},
34+
"IIS Express": {
35+
"commandName": "IISExpress",
36+
"launchBrowser": true,
37+
"launchUrl": "swagger",
38+
"environmentVariables": {
39+
"ASPNETCORE_ENVIRONMENT": "Development",
40+
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
41+
}
42+
}
43+
}
44+
}
45+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace JMayer.Example.ASPReact.Server
2+
{
3+
public class WeatherForecast
4+
{
5+
public DateOnly Date { get; set; }
6+
7+
public int TemperatureC { get; set; }
8+
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10+
11+
public string? Summary { get; set; }
12+
}
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

JMayer.Example.ASPReact.sln

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.11.35312.102
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JMayer.Example.ASPReact.Server", "JMayer.Example.ASPReact.Server\JMayer.Example.ASPReact.Server.csproj", "{BB8D94C5-3455-49AF-8815-C479BE87A232}"
7+
EndProject
8+
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "jmayer.example.aspreact.client", "jmayer.example.aspreact.client\jmayer.example.aspreact.client.esproj", "{FDF94533-717C-4CFE-BD2B-FFD35D94E87D}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{BB8D94C5-3455-49AF-8815-C479BE87A232}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{BB8D94C5-3455-49AF-8815-C479BE87A232}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{BB8D94C5-3455-49AF-8815-C479BE87A232}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{BB8D94C5-3455-49AF-8815-C479BE87A232}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{FDF94533-717C-4CFE-BD2B-FFD35D94E87D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{FDF94533-717C-4CFE-BD2B-FFD35D94E87D}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{FDF94533-717C-4CFE-BD2B-FFD35D94E87D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
23+
{FDF94533-717C-4CFE-BD2B-FFD35D94E87D}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{FDF94533-717C-4CFE-BD2B-FFD35D94E87D}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{FDF94533-717C-4CFE-BD2B-FFD35D94E87D}.Release|Any CPU.Deploy.0 = Release|Any CPU
26+
EndGlobalSection
27+
GlobalSection(SolutionProperties) = preSolution
28+
HideSolutionNode = FALSE
29+
EndGlobalSection
30+
GlobalSection(ExtensibilityGlobals) = postSolution
31+
SolutionGuid = {A16F920F-DA26-4FC4-9499-52779EA97E81}
32+
EndGlobalSection
33+
EndGlobal

0 commit comments

Comments
 (0)