Skip to content

Commit 55b6b42

Browse files
author
Xing Zhihuan
committed
添加项目文件。
1 parent 830e398 commit 55b6b42

File tree

8 files changed

+207
-0
lines changed

8 files changed

+207
-0
lines changed

WebAPI.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26730.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{40CF6C02-726D-4F73-9BFA-068154D47D8B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{40CF6C02-726D-4F73-9BFA-068154D47D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{40CF6C02-726D-4F73-9BFA-068154D47D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{40CF6C02-726D-4F73-9BFA-068154D47D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{40CF6C02-726D-4F73-9BFA-068154D47D8B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {B271C90F-66F1-4DEB-87A7-5C092CD272D9}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace WebAPI.Controllers
8+
{
9+
[Route("api/[controller]")]
10+
public class ValuesController : Controller
11+
{
12+
// GET api/values
13+
[HttpGet]
14+
public IEnumerable<string> Get()
15+
{
16+
return new string[] { "value1", "value2" };
17+
}
18+
19+
// GET api/values/5
20+
[HttpGet("{id}")]
21+
public string Get(int id)
22+
{
23+
return "value";
24+
}
25+
26+
// POST api/values
27+
[HttpPost]
28+
public void Post([FromBody]string value)
29+
{
30+
}
31+
32+
// PUT api/values/5
33+
[HttpPut("{id}")]
34+
public void Put(int id, [FromBody]string value)
35+
{
36+
}
37+
38+
// DELETE api/values/5
39+
[HttpDelete("{id}")]
40+
public void Delete(int id)
41+
{
42+
}
43+
}
44+
}

WebAPI/Program.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Builder;
7+
using Microsoft.AspNetCore.Hosting;
8+
9+
namespace WebAPI
10+
{
11+
public class Program
12+
{
13+
public static void Main(string[] args)
14+
{
15+
var host = new WebHostBuilder()
16+
.UseKestrel()
17+
.UseContentRoot(Directory.GetCurrentDirectory())
18+
.UseIISIntegration()
19+
.UseStartup<Startup>()
20+
.UseApplicationInsights()
21+
.Build();
22+
23+
host.Run();
24+
}
25+
}
26+
}

WebAPI/Properties/launchSettings.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:64396/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"launchUrl": "api/values",
15+
"environmentVariables": {
16+
"ASPNETCORE_ENVIRONMENT": "Development"
17+
}
18+
},
19+
"WebAPI": {
20+
"commandName": "Project",
21+
"launchBrowser": true,
22+
"launchUrl": "api/values",
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
},
26+
"applicationUrl": "http://localhost:64397/"
27+
}
28+
}
29+
}

WebAPI/Startup.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.Extensions.Configuration;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace WebAPI
12+
{
13+
public class Startup
14+
{
15+
public Startup(IHostingEnvironment env)
16+
{
17+
var builder = new ConfigurationBuilder()
18+
.SetBasePath(env.ContentRootPath)
19+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
20+
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
21+
.AddEnvironmentVariables();
22+
Configuration = builder.Build();
23+
}
24+
25+
public IConfigurationRoot Configuration { get; }
26+
27+
// This method gets called by the runtime. Use this method to add services to the container.
28+
public void ConfigureServices(IServiceCollection services)
29+
{
30+
// Add framework services.
31+
services.AddMvc();
32+
}
33+
34+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
35+
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
36+
{
37+
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
38+
loggerFactory.AddDebug();
39+
40+
app.UseMvc();
41+
}
42+
}
43+
}

WebAPI/WebAPI.csproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp1.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Folder Include="wwwroot\" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
13+
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
14+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
15+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
20+
</ItemGroup>
21+
22+
</Project>

WebAPI/appsettings.Development.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"IncludeScopes": false,
4+
"LogLevel": {
5+
"Default": "Debug",
6+
"System": "Information",
7+
"Microsoft": "Information"
8+
}
9+
}
10+
}

WebAPI/appsettings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"IncludeScopes": false,
4+
"LogLevel": {
5+
"Default": "Warning"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)