Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c7de1fd

Browse filesBrowse files
committed
✨ 初始化基础页面
1 parent a060613 commit c7de1fd
Copy full SHA for c7de1fd
Expand file treeCollapse file tree

26 files changed

+498
-83
lines changed
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<RootNamespace>EFCore_3_AccessToken</RootNamespace>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.36"/>
12+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<Folder Include="Controllers\"/>
17+
</ItemGroup>
18+
19+
</Project>
+49Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System.Text;
2+
using Microsoft.AspNetCore.Authentication.JwtBearer;
3+
using Microsoft.IdentityModel.Tokens;
4+
5+
var builder = WebApplication.CreateBuilder(args);
6+
7+
builder.Services.AddAuthentication(options =>
8+
{
9+
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
10+
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
11+
}).AddJwtBearer(options =>
12+
{
13+
options.RequireHttpsMetadata = false;
14+
options.SaveToken = true;
15+
options.TokenValidationParameters = new TokenValidationParameters
16+
{
17+
ValidateIssuerSigningKey = true,
18+
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("123456789134567813")),
19+
ValidIssuer = "Bunny",
20+
ValidateAudience = true,
21+
ValidAudience = "StudentApi",
22+
ValidateLifetime = true
23+
};
24+
});
25+
26+
// Add services to the container.
27+
builder.Services.AddControllers();
28+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
29+
builder.Services.AddEndpointsApiExplorer();
30+
builder.Services.AddSwaggerGen();
31+
32+
var app = builder.Build();
33+
34+
// Configure the HTTP request pipeline.
35+
if (app.Environment.IsDevelopment())
36+
{
37+
app.UseSwagger();
38+
app.UseSwaggerUI();
39+
}
40+
41+
app.UseHttpsRedirection();
42+
// Éí·ÝÑéÖ¤
43+
app.UseAuthentication();
44+
// ÊÚȨ
45+
app.UseAuthorization();
46+
47+
app.MapControllers();
48+
49+
app.Run();
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:23235",
8+
"sslPort": 44370
9+
}
10+
},
11+
"profiles": {
12+
"EFCore_3_AccessToken": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"launchUrl": "swagger",
17+
"applicationUrl": "https://localhost:7264;http://localhost:5093",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
22+
"IIS Express": {
23+
"commandName": "IISExpress",
24+
"launchBrowser": true,
25+
"launchUrl": "swagger",
26+
"environmentVariables": {
27+
"ASPNETCORE_ENVIRONMENT": "Development"
28+
}
29+
}
30+
}
31+
}

‎CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.csproj

Copy file name to clipboardExpand all lines: CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.csproj
-15Lines changed: 0 additions & 15 deletions
This file was deleted.

‎CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.http

Copy file name to clipboardExpand all lines: CSharp/WPFTutorial/ASP-1-WebApi/ASP-1-WebApi.http
-6Lines changed: 0 additions & 6 deletions
This file was deleted.

‎CSharp/WPFTutorial/ASP-1-WebApi/Program.cs

Copy file name to clipboardExpand all lines: CSharp/WPFTutorial/ASP-1-WebApi/Program.cs
-44Lines changed: 0 additions & 44 deletions
This file was deleted.
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<RootNamespace>ASP_Demo_TODO</RootNamespace>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
10+
</ItemGroup>
11+
12+
</Project>
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.Extensions.Logging;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
8+
namespace ASP_Demo_TODO.Controllers
9+
{
10+
[ApiController]
11+
[Route("[controller]")]
12+
public class WeatherForecastController : ControllerBase
13+
{
14+
private static readonly string[] Summaries = new[]
15+
{
16+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
17+
};
18+
19+
private readonly ILogger<WeatherForecastController> _logger;
20+
21+
public WeatherForecastController(ILogger<WeatherForecastController> logger)
22+
{
23+
_logger = logger;
24+
}
25+
26+
[HttpGet]
27+
public IEnumerable<WeatherForecast> Get()
28+
{
29+
var rng = new Random();
30+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
31+
{
32+
Date = DateTime.Now.AddDays(index),
33+
TemperatureC = rng.Next(-20, 55),
34+
Summary = Summaries[rng.Next(Summaries.Length)]
35+
})
36+
.ToArray();
37+
}
38+
}
39+
}
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
3+
4+
namespace ASP_Demo_TODO
5+
{
6+
public class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
CreateHostBuilder(args).Build().Run();
11+
}
12+
13+
public static IHostBuilder CreateHostBuilder(string[] args)
14+
{
15+
return Host.CreateDefaultBuilder(args)
16+
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
17+
}
18+
}
19+
}

‎CSharp/WPFTutorial/ASP-1-WebApi/Properties/launchSettings.json renamed to ‎CSharp/WPFTutorial/ASP-Demo-TODO/Properties/launchSettings.json

Copy file name to clipboardExpand all lines: CSharp/WPFTutorial/ASP-Demo-TODO/Properties/launchSettings.json
+7-17Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,25 @@
44
"windowsAuthentication": false,
55
"anonymousAuthentication": true,
66
"iisExpress": {
7-
"applicationUrl": "http://localhost:53934",
8-
"sslPort": 44328
7+
"applicationUrl": "http://localhost:9705",
8+
"sslPort": 44384
99
}
1010
},
1111
"profiles": {
12-
"http": {
13-
"commandName": "Project",
14-
"dotnetRunMessages": true,
12+
"IIS Express": {
13+
"commandName": "IISExpress",
1514
"launchBrowser": true,
1615
"launchUrl": "swagger",
17-
"applicationUrl": "http://localhost:5076",
1816
"environmentVariables": {
1917
"ASPNETCORE_ENVIRONMENT": "Development"
2018
}
2119
},
22-
"https": {
20+
"ASP_Demo_TODO": {
2321
"commandName": "Project",
24-
"dotnetRunMessages": true,
25-
"launchBrowser": true,
26-
"launchUrl": "swagger",
27-
"applicationUrl": "https://localhost:7295;http://localhost:5076",
28-
"environmentVariables": {
29-
"ASPNETCORE_ENVIRONMENT": "Development"
30-
}
31-
},
32-
"IIS Express": {
33-
"commandName": "IISExpress",
22+
"dotnetRunMessages": "true",
3423
"launchBrowser": true,
3524
"launchUrl": "swagger",
25+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
3626
"environmentVariables": {
3727
"ASPNETCORE_ENVIRONMENT": "Development"
3828
}
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.Extensions.Configuration;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.Hosting;
6+
using Microsoft.OpenApi.Models;
7+
8+
namespace ASP_Demo_TODO
9+
{
10+
public class Startup
11+
{
12+
public Startup(IConfiguration configuration)
13+
{
14+
Configuration = configuration;
15+
}
16+
17+
public IConfiguration Configuration { get; }
18+
19+
// This method gets called by the runtime. Use this method to add services to the container.
20+
public void ConfigureServices(IServiceCollection services)
21+
{
22+
services.AddControllers();
23+
services.AddSwaggerGen(c =>
24+
{
25+
c.SwaggerDoc("v1", new OpenApiInfo { Title = "ASP_Demo_TODO", Version = "v1" });
26+
});
27+
}
28+
29+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
30+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
31+
{
32+
if (env.IsDevelopment())
33+
{
34+
app.UseDeveloperExceptionPage();
35+
app.UseSwagger();
36+
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ASP_Demo_TODO v1"));
37+
}
38+
39+
app.UseHttpsRedirection();
40+
41+
app.UseRouting();
42+
43+
app.UseAuthorization();
44+
45+
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
46+
}
47+
}
48+
}
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace ASP_Demo_TODO
4+
{
5+
public class WeatherForecast
6+
{
7+
public DateTime Date { get; set; }
8+
9+
public int TemperatureC { get; set; }
10+
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12+
13+
public string Summary { get; set; }
14+
}
15+
}
+9Lines 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": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
}
9+
}
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
},
9+
"AllowedHosts": "*"
10+
}

‎CSharp/WPFTutorial/Demo-TODO/App.xaml

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<prism:PrismApplication x:Class="Demo_TODO.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:prism="http://prismlibrary.com/"
5+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
6+
StartupUri="MainWindow.xaml">
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
<ResourceDictionary.MergedDictionaries>
10+
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="DeepPurple" SecondaryColor="Lime" />
11+
<ResourceDictionary
12+
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.defaults.xaml" />
13+
</ResourceDictionary.MergedDictionaries>
14+
</ResourceDictionary>
15+
</Application.Resources>
16+
</prism:PrismApplication>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.