├── .gitattributes ├── .gitignore ├── ASPNETCoreAPI ├── ASPNETCoreAPI.sln ├── README.md ├── global.json └── src │ └── ASPNETCoreAPI │ ├── ASPNETCoreAPI.xproj │ ├── Controllers │ └── UsersController.cs │ ├── Migrations │ ├── 20160801075113_MyFirstMigration.Designer.cs │ ├── 20160801075113_MyFirstMigration.cs │ └── DataContextModelSnapshot.cs │ ├── Models │ ├── DataContext.cs │ └── User.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.json │ ├── project.json │ └── web.config ├── IdentityServer4OpenID ├── IdentityServer4OpenID.sln ├── README.md ├── global.json └── src │ ├── IdentityServer4OpenID │ ├── Config.cs │ ├── IdentityServer4OpenID.xproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Quickstart │ │ ├── Account │ │ │ ├── AccountController.cs │ │ │ ├── AccountOptions.cs │ │ │ ├── AccountService.cs │ │ │ ├── ExternalProvider.cs │ │ │ ├── LoggedOutViewModel.cs │ │ │ ├── LoginInputModel.cs │ │ │ ├── LoginViewModel.cs │ │ │ ├── LogoutInputModel.cs │ │ │ └── LogoutViewModel.cs │ │ ├── Consent │ │ │ ├── ConsentController.cs │ │ │ ├── ConsentInputModel.cs │ │ │ ├── ConsentOptions.cs │ │ │ ├── ConsentService.cs │ │ │ ├── ConsentViewModel.cs │ │ │ ├── ProcessConsentResult.cs │ │ │ └── ScopeViewModel.cs │ │ ├── Home │ │ │ ├── ErrorViewModel.cs │ │ │ └── HomeController.cs │ │ ├── SecurityHeadersAttribute.cs │ │ └── TestUsers.cs │ ├── Startup.cs │ ├── Views │ │ ├── Account │ │ │ ├── LoggedOut.cshtml │ │ │ ├── Login.cshtml │ │ │ └── Logout.cshtml │ │ ├── Consent │ │ │ ├── Index.cshtml │ │ │ └── _ScopeListItem.cshtml │ │ ├── Home │ │ │ └── Index.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _Layout.cshtml │ │ │ └── _ValidationSummary.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── appsettings.json │ ├── bundleconfig.json │ ├── project.json │ ├── web.config │ └── wwwroot │ │ ├── css │ │ ├── site.css │ │ ├── site.less │ │ └── site.min.css │ │ ├── favicon.ico │ │ ├── icon.jpg │ │ ├── icon.png │ │ ├── js │ │ └── signout-redirect.js │ │ └── lib │ │ ├── bootstrap │ │ ├── css │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ └── bootstrap.min.css │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ └── js │ │ │ ├── bootstrap.js │ │ │ └── bootstrap.min.js │ │ └── jquery │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ └── jquery.min.map │ └── MvcClient │ ├── .bowerrc │ ├── Controllers │ └── HomeController.cs │ ├── MvcClient.xproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── About.cshtml │ │ ├── Contact.cshtml │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ └── _Layout.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.json │ ├── bower.json │ ├── bundleconfig.json │ ├── project.json │ ├── web.config │ └── wwwroot │ ├── _references.js │ ├── css │ ├── site.css │ └── site.min.css │ ├── favicon.ico │ ├── images │ ├── banner1.svg │ ├── banner2.svg │ ├── banner3.svg │ └── banner4.svg │ ├── js │ ├── site.js │ └── site.min.js │ └── lib │ ├── bootstrap │ ├── .bower.json │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-theme.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ └── npm.js │ ├── jquery-validation-unobtrusive │ ├── .bower.json │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── .bower.json │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── .bower.json │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── NETCoreLogging ├── NETCoreLogging.sln ├── README.md ├── global.json └── src │ └── NETCoreLogging │ ├── .bowerrc │ ├── Controllers │ └── HomeController.cs │ ├── NETCoreLogging.xproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── About.cshtml │ │ ├── Contact.cshtml │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ └── _Layout.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.json │ ├── bower.json │ ├── gulpfile.js │ ├── nlog.config │ ├── package.json │ ├── project.json │ ├── web.config │ └── wwwroot │ ├── _references.js │ ├── css │ ├── site.css │ └── site.min.css │ ├── favicon.ico │ ├── images │ ├── banner1.svg │ ├── banner2.svg │ ├── banner3.svg │ └── banner4.svg │ ├── js │ ├── site.js │ └── site.min.js │ └── lib │ ├── bootstrap │ ├── .bower.json │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-theme.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ └── npm.js │ ├── jquery-validation-unobtrusive │ ├── .bower.json │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── .bower.json │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── .bower.json │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── NETCoreMySQL ├── NETCoreMySQL.sln ├── README.md ├── global.json └── src │ └── NETCoreMySQL │ ├── NETCoreMySQL.xproj │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── User.cs │ └── project.json ├── NETCoreTests ├── NETCoreTests.sln ├── README.md ├── global.json └── src │ └── NETCoreTests │ ├── NETCoreTests.xproj │ ├── Properties │ └── AssemblyInfo.cs │ ├── TestClass.cs │ └── project.json ├── NETCoreWCF ├── NETCoreWCF.sln ├── NETCoreWCF │ ├── INETCoreService.cs │ ├── NETCoreService.svc │ ├── NETCoreService.svc.cs │ ├── NETCoreWCF.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ └── Web.config ├── NETCoreWCFClient │ ├── NETCoreWCFClient.xproj │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Service References │ │ └── NETCoreService │ │ │ ├── ConnectedService.json │ │ │ └── Reference.cs │ └── project.json └── README.md ├── README.md ├── SOAPService ├── README.md ├── SOAPService.sln ├── global.json └── src │ ├── CustomMiddleware │ ├── ContractDescription.cs │ ├── CustomMiddleware.xproj │ ├── OperationDescription.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SOAPMiddleware.cs │ ├── ServiceBodyWriter.cs │ ├── ServiceDescription.cs │ └── project.json │ ├── SOAPClient │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SOAPClient.xproj │ └── project.json │ └── SOAPService │ ├── CalculatorService.cs │ ├── Controllers │ └── ValuesController.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── SOAPService.xproj │ ├── Startup.cs │ ├── appsettings.json │ ├── project.json │ └── web.config └── gRPCDemo ├── README.md ├── gRPCClient ├── App.config ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── gRPCClient.csproj └── packages.config ├── gRPCDemo.sln ├── gRPCDemo ├── Helloworld.cs ├── HelloworldGrpc.cs ├── Properties │ └── AssemblyInfo.cs ├── gRPCDemo.csproj ├── helloworld.proto └── packages.config ├── gRPCServer ├── App.config ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── gRPCServer.csproj └── packages.config └── generate.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/ASPNETCoreAPI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7ADE98C7-481C-44B0-A144-70400BB5CDDB}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{73724E1E-C04C-4535-B276-B399181EADF6}" 9 | ProjectSection(SolutionItems) = preProject 10 | global.json = global.json 11 | EndProjectSection 12 | EndProject 13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ASPNETCoreAPI", "src\ASPNETCoreAPI\ASPNETCoreAPI.xproj", "{26B92153-3A88-47F5-ABEC-9FF55CBE60EF}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {26B92153-3A88-47F5-ABEC-9FF55CBE60EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {26B92153-3A88-47F5-ABEC-9FF55CBE60EF}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {26B92153-3A88-47F5-ABEC-9FF55CBE60EF}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {26B92153-3A88-47F5-ABEC-9FF55CBE60EF}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | GlobalSection(NestedProjects) = preSolution 30 | {26B92153-3A88-47F5-ABEC-9FF55CBE60EF} = {7ADE98C7-481C-44B0-A144-70400BB5CDDB} 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/README.md: -------------------------------------------------------------------------------- 1 | #ASPNETCoreAPI 2 | 3 | [ASP.NET Core Web API 开发-RESTful API实现](http://www.cnblogs.com/linezero/p/aspnetcorewebapi-restfulapi.html) -------------------------------------------------------------------------------- /ASPNETCoreAPI/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ "src", "test" ], 3 | "sdk": { 4 | "version": "1.0.0-preview2-003121" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/ASPNETCoreAPI.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 26b92153-3a88-47f5-abec-9ff55cbe60ef 10 | ASPNETCoreAPI 11 | .\obj 12 | .\bin\ 13 | v4.5.2 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Controllers/UsersController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using ASPNETCoreAPI.Models; 7 | 8 | // For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 9 | 10 | namespace ASPNETCoreAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | public class UsersController : Controller 14 | { 15 | private DataContext Context; 16 | public UsersController(DataContext _context) 17 | { 18 | Context = _context; 19 | } 20 | // GET: api/users 21 | [HttpGet] 22 | public IActionResult Get() 23 | { 24 | return Ok(Context.Users.ToList()); 25 | } 26 | 27 | // GET api/users/5 28 | [HttpGet("{id}")] 29 | public IActionResult Get(int id) 30 | { 31 | var _user = Context.Users.FirstOrDefault(r => r.Id == id); 32 | if (_user == null) 33 | return NotFound(); 34 | return Ok(_user); 35 | } 36 | 37 | // POST api/users 38 | [HttpPost] 39 | public IActionResult Post([FromBody]User user) 40 | { 41 | Context.Add(user); 42 | Context.SaveChanges(); 43 | return Created($"api/users/{user.Id}",user); 44 | } 45 | 46 | // PUT api/users/5 47 | [HttpPut("{id}")] 48 | public IActionResult Put(int id, [FromBody]User user) 49 | { 50 | var _user = Context.Users.FirstOrDefault(r => r.Id == id); 51 | if (_user == null) 52 | return NotFound(); 53 | _user.UserName = user.UserName; 54 | _user.Password = user.Password; 55 | Context.Update(_user); 56 | Context.SaveChanges(); 57 | return Created($"api/users/{_user.Id}", _user); 58 | } 59 | 60 | // DELETE api/users/5 61 | [HttpDelete("{id}")] 62 | public IActionResult Delete(int id) 63 | { 64 | var _user = Context.Users.FirstOrDefault(r => r.Id == id); 65 | if (_user == null) 66 | return NotFound(); 67 | Context.Remove(_user); 68 | Context.SaveChanges(); 69 | return NoContent(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Migrations/20160801075113_MyFirstMigration.Designer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using ASPNETCoreAPI.Models; 7 | 8 | namespace ASPNETCoreAPI.Migrations 9 | { 10 | [DbContext(typeof(DataContext))] 11 | [Migration("20160801075113_MyFirstMigration")] 12 | partial class MyFirstMigration 13 | { 14 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 15 | { 16 | modelBuilder 17 | .HasAnnotation("ProductVersion", "1.0.0-rtm-21431"); 18 | 19 | modelBuilder.Entity("ASPNETCoreAPI.Models.User", b => 20 | { 21 | b.Property("Id") 22 | .ValueGeneratedOnAdd(); 23 | 24 | b.Property("Password"); 25 | 26 | b.Property("UserName"); 27 | 28 | b.HasKey("Id"); 29 | 30 | b.ToTable("Users"); 31 | }); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Migrations/20160801075113_MyFirstMigration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.EntityFrameworkCore.Migrations; 4 | 5 | namespace ASPNETCoreAPI.Migrations 6 | { 7 | public partial class MyFirstMigration : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.CreateTable( 12 | name: "Users", 13 | columns: table => new 14 | { 15 | Id = table.Column(nullable: false) 16 | .Annotation("Autoincrement", true), 17 | Password = table.Column(nullable: true), 18 | UserName = table.Column(nullable: true) 19 | }, 20 | constraints: table => 21 | { 22 | table.PrimaryKey("PK_Users", x => x.Id); 23 | }); 24 | } 25 | 26 | protected override void Down(MigrationBuilder migrationBuilder) 27 | { 28 | migrationBuilder.DropTable( 29 | name: "Users"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Migrations/DataContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using ASPNETCoreAPI.Models; 7 | 8 | namespace ASPNETCoreAPI.Migrations 9 | { 10 | [DbContext(typeof(DataContext))] 11 | partial class DataContextModelSnapshot : ModelSnapshot 12 | { 13 | protected override void BuildModel(ModelBuilder modelBuilder) 14 | { 15 | modelBuilder 16 | .HasAnnotation("ProductVersion", "1.0.0-rtm-21431"); 17 | 18 | modelBuilder.Entity("ASPNETCoreAPI.Models.User", b => 19 | { 20 | b.Property("Id") 21 | .ValueGeneratedOnAdd(); 22 | 23 | b.Property("Password"); 24 | 25 | b.Property("UserName"); 26 | 27 | b.HasKey("Id"); 28 | 29 | b.ToTable("Users"); 30 | }); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Models/DataContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace ASPNETCoreAPI.Models 8 | { 9 | public class DataContext : DbContext 10 | { 11 | public DataContext(DbContextOptions options) 12 | : base(options) 13 | { 14 | } 15 | public DbSet Users { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Models/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace ASPNETCoreAPI.Models 7 | { 8 | public class User 9 | { 10 | public int Id { get; set; } 11 | public string UserName { get; set; } 12 | public string Password { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Program.cs: -------------------------------------------------------------------------------- 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.Hosting; 7 | using Microsoft.AspNetCore.Builder; 8 | 9 | namespace ASPNETCoreAPI 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() 20 | .Build(); 21 | 22 | host.Run(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:11015/", 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 | "ASPNETCoreAPI": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "launchUrl": "http://localhost:5000/api/users", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/Startup.cs: -------------------------------------------------------------------------------- 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 | using Microsoft.AspNetCore.Mvc; 11 | using Newtonsoft.Json; 12 | using ASPNETCoreAPI.Models; 13 | using Microsoft.EntityFrameworkCore; 14 | 15 | namespace ASPNETCoreAPI 16 | { 17 | public class Startup 18 | { 19 | public Startup(IHostingEnvironment env) 20 | { 21 | var builder = new ConfigurationBuilder() 22 | .SetBasePath(env.ContentRootPath) 23 | .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) 24 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) 25 | .AddEnvironmentVariables(); 26 | Configuration = builder.Build(); 27 | } 28 | 29 | public IConfigurationRoot Configuration { get; } 30 | 31 | // This method gets called by the runtime. Use this method to add services to the container. 32 | public void ConfigureServices(IServiceCollection services) 33 | { 34 | var connection = "Filename=apidemo.db"; 35 | services.AddDbContext(options => options.UseSqlite(connection)); 36 | // Add framework services. 37 | services.AddMvc().AddJsonOptions(r=>r.SerializerSettings.ContractResolver= new Newtonsoft.Json.Serialization.DefaultContractResolver()); 38 | } 39 | 40 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 41 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 42 | { 43 | loggerFactory.AddConsole(Configuration.GetSection("Logging")); 44 | loggerFactory.AddDebug(); 45 | 46 | app.UseMvc(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.App": { 4 | "version": "1.0.0", 5 | "type": "platform" 6 | }, 7 | "Microsoft.AspNetCore.Mvc": "1.0.0", 8 | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 9 | "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", 10 | "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 11 | "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", 12 | "Microsoft.Extensions.Configuration.Json": "1.0.0", 13 | "Microsoft.Extensions.Logging": "1.0.0", 14 | "Microsoft.Extensions.Logging.Console": "1.0.0", 15 | "Microsoft.Extensions.Logging.Debug": "1.0.0", 16 | "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", 17 | "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0", 18 | "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" 19 | }, 20 | 21 | "tools": { 22 | "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", 23 | "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" 24 | }, 25 | 26 | "frameworks": { 27 | "netcoreapp1.0": { 28 | "imports": [ 29 | "dotnet5.6", 30 | "portable-net45+win8" 31 | ] 32 | } 33 | }, 34 | 35 | "buildOptions": { 36 | "emitEntryPoint": true, 37 | "preserveCompilationContext": true 38 | }, 39 | 40 | "runtimeOptions": { 41 | "configProperties": { 42 | "System.GC.Server": true 43 | } 44 | }, 45 | 46 | "publishOptions": { 47 | "include": [ 48 | "wwwroot", 49 | "Views", 50 | "Areas/**/Views", 51 | "appsettings.json", 52 | "web.config" 53 | ] 54 | }, 55 | 56 | "scripts": { 57 | "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ASPNETCoreAPI/src/ASPNETCoreAPI/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/IdentityServer4OpenID.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{31ADAE74-26BF-4687-88B6-8940044D9AC8}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{80F9C2D5-1ED0-48C4-B44A-ABE426E462F9}" 9 | ProjectSection(SolutionItems) = preProject 10 | global.json = global.json 11 | EndProjectSection 12 | EndProject 13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MvcClient", "src\MvcClient\MvcClient.xproj", "{D3AC36DD-5101-48EE-8B77-306E59485EEE}" 14 | EndProject 15 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "IdentityServer4OpenID", "src\IdentityServer4OpenID\IdentityServer4OpenID.xproj", "{555EE32F-9E7A-497C-ABA6-3E8265DD8EBF}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {D3AC36DD-5101-48EE-8B77-306E59485EEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {D3AC36DD-5101-48EE-8B77-306E59485EEE}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {D3AC36DD-5101-48EE-8B77-306E59485EEE}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {D3AC36DD-5101-48EE-8B77-306E59485EEE}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {555EE32F-9E7A-497C-ABA6-3E8265DD8EBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {555EE32F-9E7A-497C-ABA6-3E8265DD8EBF}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {555EE32F-9E7A-497C-ABA6-3E8265DD8EBF}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {555EE32F-9E7A-497C-ABA6-3E8265DD8EBF}.Release|Any CPU.Build.0 = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | GlobalSection(NestedProjects) = preSolution 36 | {D3AC36DD-5101-48EE-8B77-306E59485EEE} = {31ADAE74-26BF-4687-88B6-8940044D9AC8} 37 | {555EE32F-9E7A-497C-ABA6-3E8265DD8EBF} = {31ADAE74-26BF-4687-88B6-8940044D9AC8} 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/README.md: -------------------------------------------------------------------------------- 1 | #IdentityServer4OpenID 2 | 3 | [IdentityServer4 使用OpenID Connect添加用户身份验证](http://www.cnblogs.com/linezero/p/identityserver4openidconnect.html) -------------------------------------------------------------------------------- /IdentityServer4OpenID/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ "src", "test" ], 3 | "sdk": { 4 | "version": "1.0.0-preview2-003131" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Config.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | using IdentityServer4; 5 | using IdentityServer4.Models; 6 | using IdentityServer4.Test; 7 | using System.Collections.Generic; 8 | using System.Security.Claims; 9 | 10 | namespace IdentityServer4OpenID 11 | { 12 | public class Config 13 | { 14 | //定义系统中的资源 15 | public static IEnumerable GetIdentityResources() 16 | { 17 | return new List 18 | { 19 | new IdentityResources.OpenId(), 20 | new IdentityResources.Profile(), 21 | }; 22 | } 23 | 24 | public static IEnumerable GetClients() 25 | { 26 | // 客户端凭据 27 | return new List 28 | { 29 | // OpenID Connect implicit 客户端 (MVC) 30 | new Client 31 | { 32 | ClientId = "mvc", 33 | ClientName = "MVC Client", 34 | AllowedGrantTypes = GrantTypes.Implicit, 35 | 36 | RedirectUris = { "http://localhost:5002/signin-oidc" }, 37 | PostLogoutRedirectUris = { "http://localhost:5002" }, 38 | //运行访问的资源 39 | AllowedScopes = 40 | { 41 | IdentityServerConstants.StandardScopes.OpenId, 42 | IdentityServerConstants.StandardScopes.Profile 43 | } 44 | } 45 | }; 46 | } 47 | 48 | //测试用户 49 | public static List GetUsers() 50 | { 51 | return new List 52 | { 53 | new TestUser 54 | { 55 | SubjectId = "1", 56 | Username = "admin", 57 | Password = "123456", 58 | 59 | Claims = new List 60 | { 61 | new Claim("name", "admin"), 62 | new Claim("website", "https://www.cnblogs.com/linezero") 63 | } 64 | }, 65 | new TestUser 66 | { 67 | SubjectId = "2", 68 | Username = "linezero", 69 | Password = "123456", 70 | 71 | Claims = new List 72 | { 73 | new Claim("name", "linezero"), 74 | new Claim("website", "https://github.com/linezero") 75 | } 76 | } 77 | }; 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/IdentityServer4OpenID.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 555ee32f-9e7a-497c-aba6-3e8265dd8ebf 10 | IdentityServer4OpenID 11 | .\obj 12 | .\bin\ 13 | v4.6.1 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Program.cs: -------------------------------------------------------------------------------- 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.Hosting; 7 | 8 | namespace IdentityServer4OpenID 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | var host = new WebHostBuilder() 15 | .UseKestrel() 16 | .UseContentRoot(Directory.GetCurrentDirectory()) 17 | .UseIISIntegration() 18 | .UseStartup() 19 | .Build(); 20 | 21 | host.Run(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:9861/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "IdentityServer4OpenID": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Account/AccountOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System; 6 | 7 | namespace IdentityServer4.Quickstart.UI 8 | { 9 | public class AccountOptions 10 | { 11 | public static bool AllowLocalLogin = true; 12 | public static bool AllowRememberLogin = true; 13 | public static TimeSpan RememberMeLoginDuration = TimeSpan.FromDays(30); 14 | 15 | public static bool ShowLogoutPrompt = true; 16 | public static bool AutomaticRedirectAfterSignOut = false; 17 | 18 | public static bool WindowsAuthenticationEnabled = true; 19 | // specify the Windows authentication schemes you want to use for authentication 20 | public static readonly string[] WindowsAuthenticationSchemes = new string[] { "Negotiate", "NTLM" }; 21 | public static readonly string WindowsAuthenticationDisplayName = "Windows"; 22 | 23 | public static string InvalidCredentialsErrorMessage = "Invalid username or password"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Account/ExternalProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer4.Quickstart.UI 6 | { 7 | public class ExternalProvider 8 | { 9 | public string DisplayName { get; set; } 10 | public string AuthenticationScheme { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Account/LoggedOutViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer4.Quickstart.UI 6 | { 7 | public class LoggedOutViewModel 8 | { 9 | public string PostLogoutRedirectUri { get; set; } 10 | public string ClientName { get; set; } 11 | public string SignOutIframeUrl { get; set; } 12 | 13 | public bool AutomaticRedirectAfterSignOut { get; set; } 14 | 15 | public string LogoutId { get; set; } 16 | public bool TriggerExternalSignout => ExternalAuthenticationScheme != null; 17 | public string ExternalAuthenticationScheme { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Account/LoginInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | namespace IdentityServer4.Quickstart.UI 8 | { 9 | public class LoginInputModel 10 | { 11 | [Required] 12 | public string Username { get; set; } 13 | [Required] 14 | public string Password { get; set; } 15 | public bool RememberLogin { get; set; } 16 | public string ReturnUrl { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Account/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace IdentityServer4.Quickstart.UI 9 | { 10 | public class LoginViewModel : LoginInputModel 11 | { 12 | public bool AllowRememberLogin { get; set; } 13 | public bool EnableLocalLogin { get; set; } 14 | public IEnumerable ExternalProviders { get; set; } 15 | 16 | public bool IsExternalLoginOnly => EnableLocalLogin == false && ExternalProviders?.Count() == 1; 17 | } 18 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Account/LogoutInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer4.Quickstart.UI 6 | { 7 | public class LogoutInputModel 8 | { 9 | public string LogoutId { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Account/LogoutViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer4.Quickstart.UI 6 | { 7 | public class LogoutViewModel : LogoutInputModel 8 | { 9 | public bool ShowLogoutPrompt { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Consent/ConsentController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityServer4.Services; 6 | using IdentityServer4.Stores; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.Extensions.Logging; 9 | using System.Threading.Tasks; 10 | 11 | namespace IdentityServer4.Quickstart.UI 12 | { 13 | /// 14 | /// This controller processes the consent UI 15 | /// 16 | [SecurityHeaders] 17 | public class ConsentController : Controller 18 | { 19 | private readonly ConsentService _consent; 20 | 21 | public ConsentController( 22 | IIdentityServerInteractionService interaction, 23 | IClientStore clientStore, 24 | IResourceStore resourceStore, 25 | ILogger logger) 26 | { 27 | _consent = new ConsentService(interaction, clientStore, resourceStore, logger); 28 | } 29 | 30 | /// 31 | /// Shows the consent screen 32 | /// 33 | /// 34 | /// 35 | [HttpGet] 36 | public async Task Index(string returnUrl) 37 | { 38 | var vm = await _consent.BuildViewModelAsync(returnUrl); 39 | if (vm != null) 40 | { 41 | return View("Index", vm); 42 | } 43 | 44 | return View("Error"); 45 | } 46 | 47 | /// 48 | /// Handles the consent screen postback 49 | /// 50 | [HttpPost] 51 | [ValidateAntiForgeryToken] 52 | public async Task Index(ConsentInputModel model) 53 | { 54 | var result = await _consent.ProcessConsent(model); 55 | 56 | if (result.IsRedirect) 57 | { 58 | return Redirect(result.RedirectUri); 59 | } 60 | 61 | if (result.HasValidationError) 62 | { 63 | ModelState.AddModelError("", result.ValidationError); 64 | } 65 | 66 | if (result.ShowView) 67 | { 68 | return View("Index", result.ViewModel); 69 | } 70 | 71 | return View("Error"); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Consent/ConsentInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace IdentityServer4.Quickstart.UI 8 | { 9 | public class ConsentInputModel 10 | { 11 | public string Button { get; set; } 12 | public IEnumerable ScopesConsented { get; set; } 13 | public bool RememberConsent { get; set; } 14 | public string ReturnUrl { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Consent/ConsentOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer4.Quickstart.UI 6 | { 7 | public class ConsentOptions 8 | { 9 | public static bool EnableOfflineAccess = true; 10 | public static string OfflineAccessDisplayName = "Offline Access"; 11 | public static string OfflineAccessDescription = "Access to your applications and resources, even when you are offline"; 12 | 13 | public static readonly string MuchChooseOneErrorMessage = "You must pick at least one permission"; 14 | public static readonly string InvalidSelectionErrorMessage = "Invalid selection"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Consent/ConsentViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace IdentityServer4.Quickstart.UI 8 | { 9 | public class ConsentViewModel : ConsentInputModel 10 | { 11 | public string ClientName { get; set; } 12 | public string ClientUrl { get; set; } 13 | public string ClientLogoUrl { get; set; } 14 | public bool AllowRememberConsent { get; set; } 15 | 16 | public IEnumerable IdentityScopes { get; set; } 17 | public IEnumerable ResourceScopes { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Consent/ProcessConsentResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer4.Quickstart.UI 6 | { 7 | public class ProcessConsentResult 8 | { 9 | public bool IsRedirect => RedirectUri != null; 10 | public string RedirectUri { get; set; } 11 | 12 | public bool ShowView => ViewModel != null; 13 | public ConsentViewModel ViewModel { get; set; } 14 | 15 | public bool HasValidationError => ValidationError != null; 16 | public string ValidationError { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Consent/ScopeViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer4.Quickstart.UI 6 | { 7 | public class ScopeViewModel 8 | { 9 | public string Name { get; set; } 10 | public string DisplayName { get; set; } 11 | public string Description { get; set; } 12 | public bool Emphasize { get; set; } 13 | public bool Required { get; set; } 14 | public bool Checked { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Home/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityServer4.Models; 6 | 7 | namespace IdentityServer4.Quickstart.UI 8 | { 9 | public class ErrorViewModel 10 | { 11 | public ErrorMessage Error { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/Home/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityServer4.Services; 6 | using Microsoft.AspNetCore.Mvc; 7 | using System.Threading.Tasks; 8 | 9 | namespace IdentityServer4.Quickstart.UI 10 | { 11 | [SecurityHeaders] 12 | public class HomeController : Controller 13 | { 14 | private readonly IIdentityServerInteractionService _interaction; 15 | 16 | public HomeController(IIdentityServerInteractionService interaction) 17 | { 18 | _interaction = interaction; 19 | } 20 | 21 | public IActionResult Index() 22 | { 23 | return View(); 24 | } 25 | 26 | /// 27 | /// Shows the error page 28 | /// 29 | public async Task Error(string errorId) 30 | { 31 | var vm = new ErrorViewModel(); 32 | 33 | // retrieve error details from identityserver 34 | var message = await _interaction.GetErrorContextAsync(errorId); 35 | if (message != null) 36 | { 37 | vm.Error = message; 38 | } 39 | 40 | return View("Error", vm); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/SecurityHeadersAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.Filters; 7 | 8 | namespace IdentityServer4.Quickstart.UI 9 | { 10 | public class SecurityHeadersAttribute : ActionFilterAttribute 11 | { 12 | public override void OnResultExecuting(ResultExecutingContext context) 13 | { 14 | var result = context.Result; 15 | if (result is ViewResult) 16 | { 17 | if (!context.HttpContext.Response.Headers.ContainsKey("X-Content-Type-Options")) 18 | { 19 | context.HttpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff"); 20 | } 21 | if (!context.HttpContext.Response.Headers.ContainsKey("X-Frame-Options")) 22 | { 23 | context.HttpContext.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); 24 | } 25 | 26 | var csp = "default-src 'self'"; 27 | // once for standards compliant browsers 28 | if (!context.HttpContext.Response.Headers.ContainsKey("Content-Security-Policy")) 29 | { 30 | context.HttpContext.Response.Headers.Add("Content-Security-Policy", csp); 31 | } 32 | // and once again for IE 33 | if (!context.HttpContext.Response.Headers.ContainsKey("X-Content-Security-Policy")) 34 | { 35 | context.HttpContext.Response.Headers.Add("X-Content-Security-Policy", csp); 36 | } 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Quickstart/TestUsers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityModel; 6 | using IdentityServer4.Test; 7 | using System.Collections.Generic; 8 | using System.Security.Claims; 9 | 10 | namespace IdentityServer4.Quickstart.UI 11 | { 12 | public class TestUsers 13 | { 14 | public static List Users = new List 15 | { 16 | new TestUser{SubjectId = "818727", Username = "alice", Password = "alice", 17 | Claims = 18 | { 19 | new Claim(JwtClaimTypes.Name, "Alice Smith"), 20 | new Claim(JwtClaimTypes.GivenName, "Alice"), 21 | new Claim(JwtClaimTypes.FamilyName, "Smith"), 22 | new Claim(JwtClaimTypes.Email, "AliceSmith@email.com"), 23 | new Claim(JwtClaimTypes.EmailVerified, "true", ClaimValueTypes.Boolean), 24 | new Claim(JwtClaimTypes.WebSite, "http://alice.com"), 25 | new Claim(JwtClaimTypes.Address, @"{ 'street_address': 'One Hacker Way', 'locality': 'Heidelberg', 'postal_code': 69118, 'country': 'Germany' }", IdentityServerConstants.ClaimValueTypes.Json) 26 | } 27 | }, 28 | new TestUser{SubjectId = "88421113", Username = "bob", Password = "bob", 29 | Claims = 30 | { 31 | new Claim(JwtClaimTypes.Name, "Bob Smith"), 32 | new Claim(JwtClaimTypes.GivenName, "Bob"), 33 | new Claim(JwtClaimTypes.FamilyName, "Smith"), 34 | new Claim(JwtClaimTypes.Email, "BobSmith@email.com"), 35 | new Claim(JwtClaimTypes.EmailVerified, "true", ClaimValueTypes.Boolean), 36 | new Claim(JwtClaimTypes.WebSite, "http://bob.com"), 37 | new Claim(JwtClaimTypes.Address, @"{ 'street_address': 'One Hacker Way', 'locality': 'Heidelberg', 'postal_code': 69118, 'country': 'Germany' }", IdentityServerConstants.ClaimValueTypes.Json), 38 | new Claim("location", "somewhere"), 39 | } 40 | }, 41 | }; 42 | } 43 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Startup.cs: -------------------------------------------------------------------------------- 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 IdentityServer4OpenID 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: true, 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 | services.AddIdentityServer() 33 | .AddTemporarySigningCredential() 34 | .AddInMemoryIdentityResources(Config.GetIdentityResources()) 35 | .AddInMemoryClients(Config.GetClients()) 36 | .AddTestUsers(Config.GetUsers()); 37 | } 38 | 39 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 40 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 41 | { 42 | loggerFactory.AddConsole(Configuration.GetSection("Logging")); 43 | loggerFactory.AddDebug(); 44 | app.UseDeveloperExceptionPage(); 45 | 46 | app.UseIdentityServer(); 47 | 48 | app.UseStaticFiles(); 49 | 50 | app.UseMvc(routes => 51 | { 52 | routes.MapRoute( 53 | name: "default", 54 | template: "{controller=Home}/{action=Index}/{id?}"); 55 | }); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Account/LoggedOut.cshtml: -------------------------------------------------------------------------------- 1 | @model LoggedOutViewModel 2 | 3 | @{ 4 | // set this so the layout rendering sees an anonymous user 5 | ViewData["signed-out"] = true; 6 | } 7 | 8 | 27 | 28 | @section scripts 29 | { 30 | @if (Model.AutomaticRedirectAfterSignOut) 31 | { 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 | @model LoginViewModel 2 | 3 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Account/Logout.cshtml: -------------------------------------------------------------------------------- 1 | @model LogoutViewModel 2 | 3 |
4 | 7 | 8 |
9 |
10 |

Would you like to logout of IdentityServer?

11 |
12 | 13 |
14 |
15 | 16 |
17 |
18 |
19 |
20 |
21 |
-------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Consent/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model ConsentViewModel 2 | 3 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Consent/_ScopeListItem.cshtml: -------------------------------------------------------------------------------- 1 | @model ScopeViewModel 2 | 3 |
  • 4 | 24 | @if (Model.Required) 25 | { 26 | (required) 27 | } 28 | @if (Model.Description != null) 29 | { 30 | 33 | } 34 |
  • -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | 
    2 | 11 | 12 |
    13 |
    14 |

    15 | IdentityServer publishes a 16 | discovery document 17 | where you can find metadata and links to all the endpoints, key material, etc. 18 |

    19 |
    20 |
    21 |
    22 |
    23 |

    24 | Here are links to the 25 | source code repository, 26 | and ready to use samples. 27 |

    28 |
    29 |
    30 |
    31 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | 3 | @{ 4 | var error = Model?.Error?.Error; 5 | var request_id = Model?.Error?.RequestId; 6 | } 7 | 8 |
    9 | 12 | 13 |
    14 |
    15 |
    16 | Sorry, there was an error 17 | 18 | @if (error != null) 19 | { 20 | 21 | 22 | : @error 23 | 24 | 25 | } 26 |
    27 | 28 | @if (request_id != null) 29 | { 30 |
    Request Id: @request_id
    31 | } 32 |
    33 |
    34 |
    35 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityServer4.Extensions 2 | @{ 3 | string name = null; 4 | if (!true.Equals(ViewData["signed-out"])) 5 | { 6 | var user = await Context.GetIdentityServerUserAsync(); 7 | name = user?.FindFirst("name")?.Value; 8 | } 9 | } 10 | 11 | 12 | 13 | 14 | 15 | 16 | IdentityServer4 17 | 18 | 19 | 20 | 21 | 22 | 23 | 53 | 54 |
    55 | @RenderBody() 56 |
    57 | 58 | 59 | 60 | @RenderSection("scripts", required: false) 61 | 62 | 63 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Shared/_ValidationSummary.cshtml: -------------------------------------------------------------------------------- 1 | @if (ViewContext.ModelState.IsValid == false) 2 | { 3 |
    4 | Error 5 |
    6 |
    7 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityServer4.Quickstart.UI 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optinally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.App": { 4 | "version": "1.0.1", 5 | "type": "platform" 6 | }, 7 | "Microsoft.AspNetCore.Diagnostics": "1.0.0", 8 | "Microsoft.AspNetCore.Mvc": "1.0.1", 9 | "Microsoft.AspNetCore.Razor.Tools": { 10 | "version": "1.0.0-preview2-final", 11 | "type": "build" 12 | }, 13 | "Microsoft.AspNetCore.Routing": "1.0.1", 14 | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 15 | "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", 16 | "Microsoft.AspNetCore.StaticFiles": "1.0.0", 17 | "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 18 | "Microsoft.Extensions.Configuration.Json": "1.0.0", 19 | "Microsoft.Extensions.Logging": "1.0.0", 20 | "Microsoft.Extensions.Logging.Console": "1.0.0", 21 | "Microsoft.Extensions.Logging.Debug": "1.0.0", 22 | "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", 23 | "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", 24 | "IdentityServer4": "1.0.0" 25 | }, 26 | 27 | "tools": { 28 | "BundlerMinifier.Core": "2.0.238", 29 | "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", 30 | "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" 31 | }, 32 | 33 | "frameworks": { 34 | "netcoreapp1.0": { 35 | "imports": [ 36 | "dotnet5.6", 37 | "portable-net45+win8" 38 | ] 39 | } 40 | }, 41 | 42 | "buildOptions": { 43 | "emitEntryPoint": true, 44 | "preserveCompilationContext": true 45 | }, 46 | 47 | "runtimeOptions": { 48 | "configProperties": { 49 | "System.GC.Server": true 50 | } 51 | }, 52 | 53 | "publishOptions": { 54 | "include": [ 55 | "wwwroot", 56 | "**/*.cshtml", 57 | "appsettings.json", 58 | "web.config" 59 | ] 60 | }, 61 | 62 | "scripts": { 63 | "prepublish": [ "bower install", "dotnet bundle" ], 64 | "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin-top: 65px; 3 | } 4 | .navbar-header { 5 | position: relative; 6 | top: -4px; 7 | } 8 | .navbar-brand > .icon-banner { 9 | position: relative; 10 | top: -2px; 11 | display: inline; 12 | } 13 | .icon { 14 | position: relative; 15 | top: -10px; 16 | } 17 | .logged-out iframe { 18 | display: none; 19 | width: 0; 20 | height: 0; 21 | } 22 | .page-consent .client-logo { 23 | float: left; 24 | } 25 | .page-consent .client-logo img { 26 | width: 80px; 27 | height: 80px; 28 | } 29 | .page-consent .consent-buttons { 30 | margin-top: 25px; 31 | } 32 | .page-consent .consent-form .consent-scopecheck { 33 | display: inline-block; 34 | margin-right: 5px; 35 | } 36 | .page-consent .consent-form .consent-description { 37 | margin-left: 25px; 38 | } 39 | .page-consent .consent-form .consent-description label { 40 | font-weight: normal; 41 | } 42 | .page-consent .consent-form .consent-remember { 43 | padding-left: 16px; 44 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/css/site.less: -------------------------------------------------------------------------------- 1 | body { 2 | margin-top: 65px; 3 | } 4 | 5 | .navbar-header { 6 | position:relative; 7 | top:-4px; 8 | } 9 | 10 | .navbar-brand > .icon-banner { 11 | position:relative; 12 | top:-2px; 13 | display:inline; 14 | } 15 | 16 | .icon { 17 | position:relative; 18 | top:-10px; 19 | } 20 | 21 | .logged-out iframe { 22 | display:none; 23 | width:0; 24 | height:0; 25 | } 26 | 27 | .page-consent { 28 | .client-logo { 29 | float: left; 30 | 31 | img { 32 | width: 80px; 33 | height: 80px; 34 | } 35 | } 36 | 37 | .consent-buttons { 38 | margin-top: 25px; 39 | } 40 | 41 | .consent-form { 42 | .consent-scopecheck { 43 | display: inline-block; 44 | margin-right: 5px; 45 | } 46 | 47 | .consent-scopecheck[disabled] { 48 | //visibility:hidden; 49 | } 50 | 51 | .consent-description { 52 | margin-left: 25px; 53 | 54 | label { 55 | font-weight: normal; 56 | } 57 | } 58 | 59 | .consent-remember { 60 | padding-left: 16px; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{margin-top:65px;}.navbar-header{position:relative;top:-4px;}.navbar-brand>.icon-banner{position:relative;top:-2px;display:inline;}.icon{position:relative;top:-10px;}.logged-out iframe{display:none;width:0;height:0;}.page-consent .client-logo{float:left;}.page-consent .client-logo img{width:80px;height:80px;}.page-consent .consent-buttons{margin-top:25px;}.page-consent .consent-form .consent-scopecheck{display:inline-block;margin-right:5px;}.page-consent .consent-form .consent-description{margin-left:25px;}.page-consent .consent-form .consent-description label{font-weight:normal;}.page-consent .consent-form .consent-remember{padding-left:16px;} -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/favicon.ico -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/icon.jpg -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/icon.png -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/js/signout-redirect.js: -------------------------------------------------------------------------------- 1 | window.addEventListener("load", function () { 2 | var a = document.querySelector("a.PostLogoutRedirectUri"); 3 | if (a) { 4 | window.location = a.href; 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/IdentityServer4OpenID/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "wwwroot/lib" 3 | } 4 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Authorization; 7 | 8 | namespace MvcClient.Controllers 9 | { 10 | [Authorize] 11 | public class HomeController : Controller 12 | { 13 | public IActionResult Index() 14 | { 15 | return View(); 16 | } 17 | 18 | public IActionResult About() 19 | { 20 | ViewData["Message"] = "Your application description page."; 21 | 22 | return View(); 23 | } 24 | 25 | public IActionResult Contact() 26 | { 27 | ViewData["Message"] = "Your contact page."; 28 | 29 | return View(); 30 | } 31 | 32 | public IActionResult Error() 33 | { 34 | return View(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/MvcClient.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | d3ac36dd-5101-48ee-8b77-306e59485eee 10 | MvcClient 11 | .\obj 12 | .\bin\ 13 | v4.6.1 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Program.cs: -------------------------------------------------------------------------------- 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.Hosting; 7 | 8 | namespace MvcClient 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | var host = new WebHostBuilder() 15 | .UseKestrel() 16 | .UseUrls("http://localhost:5002") 17 | .UseContentRoot(Directory.GetCurrentDirectory()) 18 | .UseIISIntegration() 19 | .UseStartup() 20 | .Build(); 21 | 22 | host.Run(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:9199/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "MvcClient": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Startup.cs: -------------------------------------------------------------------------------- 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 MvcClient 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: true, 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 | if (env.IsDevelopment()) 41 | { 42 | app.UseDeveloperExceptionPage(); 43 | app.UseBrowserLink(); 44 | } 45 | else 46 | { 47 | app.UseExceptionHandler("/Home/Error"); 48 | } 49 | app.UseCookieAuthentication(new CookieAuthenticationOptions 50 | { 51 | AuthenticationScheme = "Cookies" 52 | }); 53 | 54 | app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 55 | { 56 | AuthenticationScheme = "oidc", 57 | SignInScheme = "Cookies", 58 | 59 | Authority = "http://localhost:5000", 60 | RequireHttpsMetadata = false, 61 | 62 | ClientId = "mvc", 63 | SaveTokens = true 64 | }); 65 | 66 | app.UseStaticFiles(); 67 | 68 | app.UseMvc(routes => 69 | { 70 | routes.MapRoute( 71 | name: "default", 72 | template: "{controller=Home}/{action=Index}/{id?}"); 73 | }); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

    @ViewData["Title"].

    5 |

    @ViewData["Message"]

    6 | 7 |

    Use this area to provide additional information.

    8 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

    @ViewData["Title"].

    5 |

    @ViewData["Message"]

    6 | 7 |
    8 | One Microsoft Way
    9 | Redmond, WA 98052-6399
    10 | P: 11 | 425.555.0100 12 |
    13 | 14 |
    15 | Support: Support@example.com
    16 | Marketing: Marketing@example.com 17 |
    18 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
    6 | @foreach (var claim in User.Claims) 7 | { 8 |
    @claim.Type
    9 |
    @claim.Value
    10 | } 11 |
    12 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

    Error.

    6 |

    An error occurred while processing your request.

    7 | 8 |

    Development Mode

    9 |

    10 | Swapping to Development environment will display more detailed information about the error that occurred. 11 |

    12 |

    13 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 14 |

    15 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - MvcClient 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 40 |
    41 | @RenderBody() 42 |
    43 |
    44 |

    © 2016 - MvcClient

    45 |
    46 |
    47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 62 | 63 | 64 | 65 | @RenderSection("scripts", required: false) 66 | 67 | 68 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MvcClient 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asp.net", 3 | "private": true, 4 | "dependencies": { 5 | "bootstrap": "3.3.6", 6 | "jquery": "2.2.0", 7 | "jquery-validation": "1.14.0", 8 | "jquery-validation-unobtrusive": "3.2.6" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optinally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.App": { 4 | "version": "1.0.1", 5 | "type": "platform" 6 | }, 7 | "Microsoft.AspNetCore.Diagnostics": "1.0.0", 8 | "Microsoft.AspNetCore.Mvc": "1.0.1", 9 | "Microsoft.AspNetCore.Razor.Tools": { 10 | "version": "1.0.0-preview2-final", 11 | "type": "build" 12 | }, 13 | "Microsoft.AspNetCore.Routing": "1.0.1", 14 | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 15 | "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", 16 | "Microsoft.AspNetCore.StaticFiles": "1.0.0", 17 | "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 18 | "Microsoft.Extensions.Configuration.Json": "1.0.0", 19 | "Microsoft.Extensions.Logging": "1.0.0", 20 | "Microsoft.Extensions.Logging.Console": "1.0.0", 21 | "Microsoft.Extensions.Logging.Debug": "1.0.0", 22 | "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", 23 | "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", 24 | "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0", 25 | "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0" 26 | }, 27 | 28 | "tools": { 29 | "BundlerMinifier.Core": "2.0.238", 30 | "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", 31 | "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" 32 | }, 33 | 34 | "frameworks": { 35 | "netcoreapp1.0": { 36 | "imports": [ 37 | "dotnet5.6", 38 | "portable-net45+win8" 39 | ] 40 | } 41 | }, 42 | 43 | "buildOptions": { 44 | "emitEntryPoint": true, 45 | "preserveCompilationContext": true 46 | }, 47 | 48 | "runtimeOptions": { 49 | "configProperties": { 50 | "System.GC.Server": true 51 | } 52 | }, 53 | 54 | "publishOptions": { 55 | "include": [ 56 | "wwwroot", 57 | "**/*.cshtml", 58 | "appsettings.json", 59 | "web.config" 60 | ] 61 | }, 62 | 63 | "scripts": { 64 | "prepublish": [ "bower install", "dotnet bundle" ], 65 | "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/_references.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | /// 7 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Set widths on the form inputs since otherwise they're 100% wide */ 14 | input, 15 | select, 16 | textarea { 17 | max-width: 280px; 18 | } 19 | 20 | /* Carousel */ 21 | .carousel-caption p { 22 | font-size: 20px; 23 | line-height: 1.4; 24 | } 25 | 26 | /* Make .svg files in the carousel display properly in older browsers */ 27 | .carousel-inner .item img[src$=".svg"] 28 | { 29 | width: 100%; 30 | } 31 | 32 | /* Hide/rearrange for smaller screens */ 33 | @media screen and (max-width: 767px) { 34 | /* Hide captions */ 35 | .carousel-caption { 36 | display: none 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/favicon.ico -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your Javascript code. 2 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/js/site.min.js -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": "1.9.1 - 2" 33 | }, 34 | "version": "3.3.6", 35 | "_release": "3.3.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.6", 39 | "commit": "81df608a40bf0629a1dc08e584849bb1e43e0b7a" 40 | }, 41 | "_source": "git://github.com/twbs/bootstrap.git", 42 | "_target": "3.3.6", 43 | "_originalSource": "bootstrap" 44 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2015 Twitter, Inc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.6", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.6", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.6", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "2.2.0", 16 | "_release": "2.2.0", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "2.2.0", 20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5" 21 | }, 22 | "_source": "git://github.com/jquery/jquery-dist.git", 23 | "_target": "2.2.0", 24 | "_originalSource": "jquery" 25 | } -------------------------------------------------------------------------------- /IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright jQuery Foundation and other contributors, https://jquery.org/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /NETCoreLogging/NETCoreLogging.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{750DB4F6-4C5E-47F8-9BD9-D30181C64F39}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{83FED358-0394-485F-BB82-0C59D67701BC}" 9 | ProjectSection(SolutionItems) = preProject 10 | global.json = global.json 11 | EndProjectSection 12 | EndProject 13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NETCoreLogging", "src\NETCoreLogging\NETCoreLogging.xproj", "{CB2F89A8-8E72-4084-936F-C2A0D27F161E}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | GlobalSection(NestedProjects) = preSolution 30 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E} = {750DB4F6-4C5E-47F8-9BD9-D30181C64F39} 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /NETCoreLogging/README.md: -------------------------------------------------------------------------------- 1 | #NETCoreLogging 2 | 3 | [ASP.NET Core 开发-Logging 使用NLog 写日志文件](http://www.cnblogs.com/linezero/p/Logging.html) -------------------------------------------------------------------------------- /NETCoreLogging/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ "src", "test" ], 3 | "sdk": { 4 | "version": "1.0.0-preview1-002702" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "wwwroot/lib" 3 | } 4 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace NETCoreLogging.Controllers 9 | { 10 | public class HomeController : Controller 11 | { 12 | private readonly ILogger _logger; 13 | 14 | public HomeController(ILogger logger) 15 | { 16 | _logger = logger; 17 | } 18 | public IActionResult Index() 19 | { 20 | _logger.LogInformation("你访问了首页"); 21 | _logger.LogWarning("警告信息"); 22 | _logger.LogError("错误信息"); 23 | return View(); 24 | } 25 | 26 | public IActionResult About() 27 | { 28 | ViewData["Message"] = "Your application description page."; 29 | 30 | return View(); 31 | } 32 | 33 | public IActionResult Contact() 34 | { 35 | ViewData["Message"] = "Your contact page."; 36 | 37 | return View(); 38 | } 39 | 40 | public IActionResult Error() 41 | { 42 | return View(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/NETCoreLogging.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | cb2f89a8-8e72-4084-936f-c2a0d27f161e 10 | NETCoreLogging 11 | .\obj 12 | .\bin\ 13 | v4.5.2 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Program.cs: -------------------------------------------------------------------------------- 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.Hosting; 7 | 8 | namespace NETCoreLogging 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | var host = new WebHostBuilder() 15 | .UseKestrel() 16 | .UseContentRoot(Directory.GetCurrentDirectory()) 17 | .UseIISIntegration() 18 | .UseStartup() 19 | .Build(); 20 | 21 | host.Run(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:5382/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "NETCoreLogging": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Startup.cs: -------------------------------------------------------------------------------- 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 | using System.Text; 11 | using NLog.Extensions.Logging; 12 | 13 | namespace NETCoreLogging 14 | { 15 | public class Startup 16 | { 17 | public Startup(IHostingEnvironment env) 18 | { 19 | var builder = new ConfigurationBuilder() 20 | .SetBasePath(env.ContentRootPath) 21 | .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) 22 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) 23 | .AddEnvironmentVariables(); 24 | Configuration = builder.Build(); 25 | } 26 | 27 | public IConfigurationRoot Configuration { get; } 28 | 29 | // This method gets called by the runtime. Use this method to add services to the container. 30 | public void ConfigureServices(IServiceCollection services) 31 | { 32 | // Add framework services. 33 | services.AddMvc(); 34 | } 35 | 36 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 37 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 38 | { 39 | loggerFactory.AddNLog();//添加NLog 40 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); 41 | loggerFactory.AddConsole(Configuration.GetSection("Logging")); 42 | loggerFactory.AddDebug(); 43 | 44 | if (env.IsDevelopment()) 45 | { 46 | app.UseDeveloperExceptionPage(); 47 | app.UseBrowserLink(); 48 | } 49 | else 50 | { 51 | app.UseExceptionHandler("/Home/Error"); 52 | } 53 | 54 | app.UseStaticFiles(); 55 | 56 | app.UseMvc(routes => 57 | { 58 | routes.MapRoute( 59 | name: "default", 60 | template: "{controller=Home}/{action=Index}/{id?}"); 61 | }); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

    @ViewData["Title"].

    5 |

    @ViewData["Message"]

    6 | 7 |

    Use this area to provide additional information.

    8 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

    @ViewData["Title"].

    5 |

    @ViewData["Message"]

    6 | 7 |
    8 | One Microsoft Way
    9 | Redmond, WA 98052-6399
    10 | P: 11 | 425.555.0100 12 |
    13 | 14 |
    15 | Support: Support@example.com
    16 | Marketing: Marketing@example.com 17 |
    18 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

    Error.

    6 |

    An error occurred while processing your request.

    7 | 8 |

    Development Mode

    9 |

    10 | Swapping to Development environment will display more detailed information about the error that occurred. 11 |

    12 |

    13 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 14 |

    15 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - NETCoreLogging 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 40 |
    41 | @RenderBody() 42 |
    43 |
    44 |

    © 2016 - NETCoreLogging

    45 |
    46 |
    47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 62 | 63 | 64 | 65 | @RenderSection("scripts", required: false) 66 | 67 | 68 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using NETCoreLogging 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asp.net", 3 | "private": true, 4 | "dependencies": { 5 | "bootstrap": "3.3.6", 6 | "jquery": "2.2.0", 7 | "jquery-validation": "1.14.0", 8 | "jquery-validation-unobtrusive": "3.2.6" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/gulpfile.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | 4 | var gulp = require("gulp"), 5 | rimraf = require("rimraf"), 6 | concat = require("gulp-concat"), 7 | cssmin = require("gulp-cssmin"), 8 | uglify = require("gulp-uglify"); 9 | 10 | var webroot = "./wwwroot/"; 11 | 12 | var paths = { 13 | js: webroot + "js/**/*.js", 14 | minJs: webroot + "js/**/*.min.js", 15 | css: webroot + "css/**/*.css", 16 | minCss: webroot + "css/**/*.min.css", 17 | concatJsDest: webroot + "js/site.min.js", 18 | concatCssDest: webroot + "css/site.min.css" 19 | }; 20 | 21 | gulp.task("clean:js", function (cb) { 22 | rimraf(paths.concatJsDest, cb); 23 | }); 24 | 25 | gulp.task("clean:css", function (cb) { 26 | rimraf(paths.concatCssDest, cb); 27 | }); 28 | 29 | gulp.task("clean", ["clean:js", "clean:css"]); 30 | 31 | gulp.task("min:js", function () { 32 | return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) 33 | .pipe(concat(paths.concatJsDest)) 34 | .pipe(uglify()) 35 | .pipe(gulp.dest(".")); 36 | }); 37 | 38 | gulp.task("min:css", function () { 39 | return gulp.src([paths.css, "!" + paths.minCss]) 40 | .pipe(concat(paths.concatCssDest)) 41 | .pipe(cssmin()) 42 | .pipe(gulp.dest(".")); 43 | }); 44 | 45 | gulp.task("min", ["min:js", "min:css"]); 46 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/nlog.config: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asp.net", 3 | "version": "0.0.0", 4 | "private": true, 5 | "devDependencies": { 6 | "gulp": "3.8.11", 7 | "gulp-concat": "2.5.2", 8 | "gulp-cssmin": "0.1.7", 9 | "gulp-uglify": "1.2.0", 10 | "rimraf": "2.2.8" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/project.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/project.json -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/_references.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | /// 7 | /// 8 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Set widths on the form inputs since otherwise they're 100% wide */ 14 | input, 15 | select, 16 | textarea { 17 | max-width: 280px; 18 | } 19 | 20 | /* Carousel */ 21 | .carousel-caption p { 22 | font-size: 20px; 23 | line-height: 1.4; 24 | } 25 | /* Hide/rearrange for smaller screens */ 26 | @media screen and (max-width: 767px) { 27 | /* Hide captions */ 28 | .carousel-caption { 29 | display: none 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/favicon.ico -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your Javascript code. 2 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/js/site.min.js -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": "1.9.1 - 2" 33 | }, 34 | "version": "3.3.6", 35 | "_release": "3.3.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.6", 39 | "commit": "81df608a40bf0629a1dc08e584849bb1e43e0b7a" 40 | }, 41 | "_source": "git://github.com/twbs/bootstrap.git", 42 | "_target": "3.3.6", 43 | "_originalSource": "bootstrap" 44 | } -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2015 Twitter, Inc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.6", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.6", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.6", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "2.2.0", 16 | "_release": "2.2.0", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "2.2.0", 20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5" 21 | }, 22 | "_source": "git://github.com/jquery/jquery-dist.git", 23 | "_target": "2.2.0", 24 | "_originalSource": "jquery" 25 | } -------------------------------------------------------------------------------- /NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright jQuery Foundation and other contributors, https://jquery.org/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /NETCoreMySQL/NETCoreMySQL.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{927FDD21-3815-43C3-8EF6-D47AA09B4DBA}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5D5EF17A-AF3C-440B-9D74-38904EC935A0}" 9 | ProjectSection(SolutionItems) = preProject 10 | global.json = global.json 11 | EndProjectSection 12 | EndProject 13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NETCoreMySQL", "src\NETCoreMySQL\NETCoreMySQL.xproj", "{DE5B5364-4955-42F5-95C0-BD0E2AECF10B}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | GlobalSection(NestedProjects) = preSolution 30 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B} = {927FDD21-3815-43C3-8EF6-D47AA09B4DBA} 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /NETCoreMySQL/README.md: -------------------------------------------------------------------------------- 1 | #NETCoreMySQL 2 | 3 | [.NET Core 使用Dapper 操作MySQL](http://www.cnblogs.com/linezero/p/NETCoreMySQL.html) 4 | 5 | [MySQL官方.NET Core驱动已出,支持EF Core](http://www.cnblogs.com/linezero/p/5806814.html) -------------------------------------------------------------------------------- /NETCoreMySQL/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ "src", "test" ], 3 | "sdk": { 4 | "version": "1.0.0-preview2-003121" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /NETCoreMySQL/src/NETCoreMySQL/NETCoreMySQL.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | de5b5364-4955-42f5-95c0-bd0e2aecf10b 10 | NETCoreMySQL 11 | .\obj 12 | .\bin\ 13 | v4.5.2 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /NETCoreMySQL/src/NETCoreMySQL/Program.cs: -------------------------------------------------------------------------------- 1 | using MySql.Data.MySqlClient; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Dapper; 7 | using System.Text; 8 | using Microsoft.Extensions.Configuration; 9 | using System.IO; 10 | 11 | namespace NETCoreMySQL 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); 18 | MySqlConnection con = new MySqlConnection("server=127.0.0.1;database=test;uid=root;pwd=;charset='gbk';SslMode=None"); 19 | //新增数据 20 | con.Execute("insert into user values(null, '测试', 'http://www.cnblogs.com/linezero/', 18)"); 21 | //新增数据返回自增id 22 | var id = con.QueryFirst("insert into user values(null, 'linezero', 'http://www.cnblogs.com/linezero/', 18);select last_insert_id();"); 23 | //修改数据 24 | con.Execute("update user set UserName = 'linezero123' where Id = @Id", new { Id = id }); 25 | //查询数据 26 | var list = con.Query("select * from user"); 27 | foreach (var item in list) 28 | { 29 | Console.WriteLine($"用户名:{item.UserName} 链接:{item.Url}"); 30 | } 31 | //删除数据 32 | con.Execute("delete from user where Id = @Id", new { Id = id }); 33 | Console.WriteLine("删除数据后的结果"); 34 | list = con.Query("select * from user"); 35 | foreach (var item in list) 36 | { 37 | Console.WriteLine($"用户名:{item.UserName} 链接:{item.Url}"); 38 | } 39 | Console.ReadKey(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /NETCoreMySQL/src/NETCoreMySQL/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("NETCoreMySQL")] 11 | [assembly: AssemblyTrademark("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("de5b5364-4955-42f5-95c0-bd0e2aecf10b")] 20 | -------------------------------------------------------------------------------- /NETCoreMySQL/src/NETCoreMySQL/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace NETCoreMySQL 7 | { 8 | public class User 9 | { 10 | public int Id { get; set; } 11 | public string UserName { get; set; } 12 | public string Url { get; set; } 13 | public int Age { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NETCoreMySQL/src/NETCoreMySQL/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "Dapper": "1.50.2", 9 | "Microsoft.Extensions.Configuration": "1.0.0", 10 | "Microsoft.Extensions.Configuration.Json": "1.0.0", 11 | "Microsoft.NETCore.App": { 12 | "type": "platform", 13 | "version": "1.0.0" 14 | }, 15 | "MySql.Data.Core": "7.0.4-IR-191", 16 | "System.Text.Encoding.CodePages": "4.0.1" 17 | }, 18 | 19 | "frameworks": { 20 | "netcoreapp1.0": { 21 | "imports": "dnxcore50" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NETCoreTests/NETCoreTests.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D8DEB2DD-9E0B-4A51-8382-BF1BE12C9927}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AA861EC4-F571-485E-BF6C-AD32569363C6}" 9 | ProjectSection(SolutionItems) = preProject 10 | global.json = global.json 11 | EndProjectSection 12 | EndProject 13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NETCoreTests", "src\NETCoreTests\NETCoreTests.xproj", "{5E1F4593-16B7-4F5F-8F3C-512537E7820D}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | GlobalSection(NestedProjects) = preSolution 30 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D} = {D8DEB2DD-9E0B-4A51-8382-BF1BE12C9927} 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /NETCoreTests/README.md: -------------------------------------------------------------------------------- 1 | #NETCoreTests 2 | 3 | [.NET Core 单元测试 MSTest](http://www.cnblogs.com/linezero/p/MSTest.html) -------------------------------------------------------------------------------- /NETCoreTests/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ "src", "test" ], 3 | "sdk": { 4 | "version": "1.0.0-preview1-002702" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /NETCoreTests/src/NETCoreTests/NETCoreTests.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 5e1f4593-16b7-4f5f-8f3c-512537e7820d 10 | NETCoreTests 11 | .\obj 12 | .\bin\ 13 | v4.5.2 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /NETCoreTests/src/NETCoreTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("NETCoreTests")] 11 | [assembly: AssemblyTrademark("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("5e1f4593-16b7-4f5f-8f3c-512537e7820d")] 20 | -------------------------------------------------------------------------------- /NETCoreTests/src/NETCoreTests/TestClass.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace NETCoreTests 4 | { 5 | // This project can output the Class library as a NuGet Package. 6 | // To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build". 7 | [TestClass] 8 | public class TestClass 9 | { 10 | [TestMethod] 11 | public void TestMethodPassing() 12 | { 13 | Assert.IsTrue(true); 14 | } 15 | 16 | [TestMethod] 17 | public void TestMethodFailing() 18 | { 19 | Assert.IsTrue(false); 20 | } 21 | 22 | [TestMethod] 23 | public void TestStringEqual() 24 | { 25 | var blogname = "linezero"; 26 | Assert.AreEqual(blogname,"LineZero"); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NETCoreTests/src/NETCoreTests/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | 4 | "testRunner": "mstest", 5 | 6 | "dependencies": { 7 | "dotnet-test-mstest": "1.0.0-preview", 8 | "MSTest.TestFramework": "1.0.0-preview" 9 | }, 10 | 11 | "frameworks": { 12 | "netcoreapp1.0": { 13 | "imports": [ 14 | "dnxcore50", 15 | "portable-net45+win8" 16 | ], 17 | 18 | "dependencies": { 19 | "Microsoft.NETCore.App": { 20 | "version": "1.0.0-rc2-3002702", 21 | "type": "platform" 22 | } 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCF.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NETCoreWCF", "NETCoreWCF\NETCoreWCF.csproj", "{5BDB0773-0A70-47D8-8937-4072137B2713}" 7 | EndProject 8 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NETCoreWCFClient", "NETCoreWCFClient\NETCoreWCFClient.xproj", "{C9652E3B-F6F1-4106-9EE5-150140D7B84F}" 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 | {5BDB0773-0A70-47D8-8937-4072137B2713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {5BDB0773-0A70-47D8-8937-4072137B2713}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {5BDB0773-0A70-47D8-8937-4072137B2713}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {5BDB0773-0A70-47D8-8937-4072137B2713}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {C9652E3B-F6F1-4106-9EE5-150140D7B84F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {C9652E3B-F6F1-4106-9EE5-150140D7B84F}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {C9652E3B-F6F1-4106-9EE5-150140D7B84F}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {C9652E3B-F6F1-4106-9EE5-150140D7B84F}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCF/INETCoreService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.ServiceModel; 6 | using System.ServiceModel.Web; 7 | using System.Text; 8 | 9 | namespace NETCoreWCF 10 | { 11 | // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。 12 | [ServiceContract] 13 | public interface INETCoreService 14 | { 15 | 16 | [OperationContract] 17 | string GetData(int value); 18 | 19 | [OperationContract] 20 | CompositeType GetDataUsingDataContract(CompositeType composite); 21 | 22 | [OperationContract] 23 | List GetList(); 24 | 25 | // TODO: 在此添加您的服务操作 26 | } 27 | 28 | 29 | // 使用下面示例中说明的数据约定将复合类型添加到服务操作。 30 | [DataContract] 31 | public class CompositeType 32 | { 33 | bool boolValue = true; 34 | string stringValue = "Hello "; 35 | 36 | [DataMember] 37 | public bool BoolValue 38 | { 39 | get { return boolValue; } 40 | set { boolValue = value; } 41 | } 42 | 43 | [DataMember] 44 | public string StringValue 45 | { 46 | get { return stringValue; } 47 | set { stringValue = value; } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCF/NETCoreService.svc: -------------------------------------------------------------------------------- 1 | <%@ ServiceHost Language="C#" Debug="true" Service="NETCoreWCF.NETCoreService" CodeBehind="NETCoreService.svc.cs" %> -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCF/NETCoreService.svc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.ServiceModel; 6 | using System.ServiceModel.Web; 7 | using System.Text; 8 | 9 | namespace NETCoreWCF 10 | { 11 | // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Service1”。 12 | // 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 Service1.svc 或 Service1.svc.cs,然后开始调试。 13 | public class NETCoreService : INETCoreService 14 | { 15 | public string GetData(int value) 16 | { 17 | return string.Format("You entered: {0}", value); 18 | } 19 | 20 | public CompositeType GetDataUsingDataContract(CompositeType composite) 21 | { 22 | if (composite == null) 23 | { 24 | throw new ArgumentNullException("composite"); 25 | } 26 | if (composite.BoolValue) 27 | { 28 | composite.StringValue += "Suffix"; 29 | } 30 | return composite; 31 | } 32 | 33 | public List GetList() 34 | { 35 | var list = new List(); 36 | list.Add("cnblogs"); 37 | list.Add("linezero"); 38 | list.Add("测试"); 39 | return list; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCF/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NETCoreWCF")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NETCoreWCF")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("5bdb0773-0a70-47d8-8937-4072137b2713")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 您可以指定所有值,也可以通过使用“*”来使用 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCF/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 30 | 31 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCF/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 31 | 32 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCF/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCFClient/NETCoreWCFClient.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 10 | c9652e3b-f6f1-4106-9ee5-150140d7b84f 11 | NETCoreWCFClient 12 | .\obj 13 | .\bin\ 14 | v4.5.2 15 | 16 | 17 | 18 | 2.0 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCFClient/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using NETCoreService; 6 | using System.Text; 7 | 8 | namespace NETCoreWCFClient 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); 15 | NETCoreServiceClient client = new NETCoreServiceClient(); 16 | var t = client.GetDataAsync(100); 17 | Console.WriteLine(t.Result); 18 | var t1 = client.GetListAsync(); 19 | foreach (var item in t1.Result) 20 | { 21 | Console.WriteLine(item); 22 | } 23 | CompositeType composite = new CompositeType(); 24 | composite.BoolValue = true; 25 | composite.StringValue = "客户端调用"; 26 | var t2 = client.GetDataUsingDataContractAsync(composite); 27 | Console.WriteLine(t2.Result.StringValue); 28 | Console.ReadKey(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCFClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("NETCoreWCFClient")] 11 | [assembly: AssemblyTrademark("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("c9652e3b-f6f1-4106-9ee5-150140d7b84f")] 20 | -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCFClient/Service References/NETCoreService/ConnectedService.json: -------------------------------------------------------------------------------- 1 | { 2 | "ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf", 3 | "Version": "0.2.20609.0", 4 | "GettingStartedDocument": { 5 | "Uri": "http://go.microsoft.com/fwlink/?LinkId=703956" 6 | } 7 | } -------------------------------------------------------------------------------- /NETCoreWCF/NETCoreWCFClient/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | "dependencies": { 7 | "Microsoft.NETCore.App": { 8 | "type": "platform", 9 | "version": "1.0.0-rc2-3002702" 10 | }, 11 | "System.Text.Encoding.CodePages": "4.0.1-rc2-24027" 12 | }, 13 | "frameworks": { 14 | "netcoreapp1.0": { 15 | "imports": "dnxcore50", 16 | "dependencies": { 17 | "System.Diagnostics.Tools": "4.0.1-rc2-24027", 18 | "System.Net.NameResolution": "4.0.0-rc2-24027", 19 | "System.Net.Security": "4.0.0-rc2-24027", 20 | "System.Private.ServiceModel": "4.1.0-rc2-24027", 21 | "System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027", 22 | "System.Runtime.Serialization.Xml": "4.1.1-rc2-24027", 23 | "System.Security.Principal.Windows": "4.0.0-rc2-24027", 24 | "System.ServiceModel.Duplex": "4.0.1-rc2-24027", 25 | "System.ServiceModel.Http": "4.1.0-rc2-24027", 26 | "System.ServiceModel.NetTcp": "4.1.0-rc2-24027", 27 | "System.ServiceModel.Primitives": "4.1.0-rc2-24027", 28 | "System.ServiceModel.Security": "4.0.1-rc2-24027" 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /NETCoreWCF/README.md: -------------------------------------------------------------------------------- 1 | #NETCoreWCF 2 | 3 | [.NET Core 调用WCF 服务](http://www.cnblogs.com/linezero/p/NETCoreWCF.html) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blog 2 | Blog Sample Code 3 | 4 | 博客示例代码 5 | 6 | 博客地址:http://www.cnblogs.com/linezero 7 | -------------------------------------------------------------------------------- /SOAPService/README.md: -------------------------------------------------------------------------------- 1 | #SOAPService 2 | 3 | [ASP.NET Core中间件(Middleware)实现WCF SOAP服务端解析](http://www.cnblogs.com/linezero/p/aspnetcoresoap.html) -------------------------------------------------------------------------------- /SOAPService/SOAPService.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{47C331FE-90FF-4C1E-BCD1-98152CE2CCF8}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3CCB24EC-179D-4B74-A33C-67E4E8D22CA0}" 9 | ProjectSection(SolutionItems) = preProject 10 | global.json = global.json 11 | EndProjectSection 12 | EndProject 13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SOAPService", "src\SOAPService\SOAPService.xproj", "{3DDF128C-8E5A-4222-8AA3-9808BA4CA880}" 14 | EndProject 15 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SOAPClient", "src\SOAPClient\SOAPClient.xproj", "{2B13196B-7529-4E79-AA72-9AF00F71C459}" 16 | EndProject 17 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CustomMiddleware", "src\CustomMiddleware\CustomMiddleware.xproj", "{4524A25D-3510-48A1-A645-7DCD9D88E40F}" 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Any CPU = Debug|Any CPU 22 | Release|Any CPU = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {2B13196B-7529-4E79-AA72-9AF00F71C459}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {2B13196B-7529-4E79-AA72-9AF00F71C459}.Debug|Any CPU.Build.0 = Debug|Any CPU 31 | {2B13196B-7529-4E79-AA72-9AF00F71C459}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {2B13196B-7529-4E79-AA72-9AF00F71C459}.Release|Any CPU.Build.0 = Release|Any CPU 33 | {4524A25D-3510-48A1-A645-7DCD9D88E40F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {4524A25D-3510-48A1-A645-7DCD9D88E40F}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {4524A25D-3510-48A1-A645-7DCD9D88E40F}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {4524A25D-3510-48A1-A645-7DCD9D88E40F}.Release|Any CPU.Build.0 = Release|Any CPU 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | GlobalSection(NestedProjects) = preSolution 42 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880} = {47C331FE-90FF-4C1E-BCD1-98152CE2CCF8} 43 | {2B13196B-7529-4E79-AA72-9AF00F71C459} = {47C331FE-90FF-4C1E-BCD1-98152CE2CCF8} 44 | {4524A25D-3510-48A1-A645-7DCD9D88E40F} = {47C331FE-90FF-4C1E-BCD1-98152CE2CCF8} 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /SOAPService/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ "src", "test" ], 3 | "sdk": { 4 | "version": "1.0.0-preview2-003121" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SOAPService/src/CustomMiddleware/ContractDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.ServiceModel; 6 | using System.Threading.Tasks; 7 | 8 | namespace CustomMiddleware 9 | { 10 | public class ContractDescription 11 | { 12 | public ServiceDescription Service { get; private set; } 13 | public string Name { get; private set; } 14 | public string Namespace { get; private set; } 15 | public Type ContractType { get; private set; } 16 | public IEnumerable Operations { get; private set; } 17 | 18 | public ContractDescription(ServiceDescription service, Type contractType, ServiceContractAttribute attribute) 19 | { 20 | Service = service; 21 | ContractType = contractType; 22 | Namespace = attribute.Namespace ?? "http://tempuri.org/"; // Namespace defaults to http://tempuri.org/ 23 | Name = attribute.Name ?? ContractType.Name; // Name defaults to the type name 24 | 25 | var operations = new List(); 26 | foreach (var operationMethodInfo in ContractType.GetTypeInfo().DeclaredMethods) 27 | { 28 | foreach (var operationContract in operationMethodInfo.GetCustomAttributes()) 29 | { 30 | operations.Add(new OperationDescription(this, operationMethodInfo, operationContract)); 31 | } 32 | } 33 | Operations = operations; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SOAPService/src/CustomMiddleware/CustomMiddleware.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 10 | 4524a25d-3510-48a1-a645-7dcd9d88e40f 11 | CustomMiddleware 12 | .\obj 13 | .\bin\ 14 | v4.5.2 15 | 16 | 17 | 18 | 2.0 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /SOAPService/src/CustomMiddleware/OperationDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.ServiceModel; 6 | using System.Threading.Tasks; 7 | 8 | namespace CustomMiddleware 9 | { 10 | public class OperationDescription 11 | { 12 | public ContractDescription Contract { get; private set; } 13 | public string SoapAction { get; private set; } 14 | public string ReplyAction { get; private set; } 15 | public string Name { get; private set; } 16 | public MethodInfo DispatchMethod { get; private set; } 17 | public bool IsOneWay { get; private set; } 18 | 19 | public OperationDescription(ContractDescription contract, MethodInfo operationMethod, OperationContractAttribute contractAttribute) 20 | { 21 | Contract = contract; 22 | Name = contractAttribute.Name ?? operationMethod.Name; 23 | SoapAction = contractAttribute.Action ?? $"{contract.Namespace.TrimEnd('/')}/{contract.Name}/{Name}"; 24 | IsOneWay = contractAttribute.IsOneWay; 25 | ReplyAction = contractAttribute.ReplyAction; 26 | DispatchMethod = operationMethod; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SOAPService/src/CustomMiddleware/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("CustomMiddleware")] 11 | [assembly: AssemblyTrademark("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("4524a25d-3510-48a1-a645-7dcd9d88e40f")] 20 | -------------------------------------------------------------------------------- /SOAPService/src/CustomMiddleware/ServiceBodyWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.ServiceModel.Channels; 6 | using System.Threading.Tasks; 7 | using System.Xml; 8 | 9 | namespace CustomMiddleware 10 | { 11 | public class ServiceBodyWriter : BodyWriter 12 | { 13 | string ServiceNamespace; 14 | string EnvelopeName; 15 | string ResultName; 16 | object Result; 17 | 18 | public ServiceBodyWriter(string serviceNamespace, string envelopeName, string resultName, object result) : base(isBuffered: true) 19 | { 20 | ServiceNamespace = serviceNamespace; 21 | EnvelopeName = envelopeName; 22 | ResultName = resultName; 23 | Result = result; 24 | } 25 | 26 | protected override void OnWriteBodyContents(XmlDictionaryWriter writer) 27 | { 28 | writer.WriteStartElement(EnvelopeName, ServiceNamespace); 29 | var serializer = new DataContractSerializer(Result.GetType(), ResultName, ServiceNamespace); 30 | serializer.WriteObject(writer, Result); 31 | writer.WriteEndElement(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SOAPService/src/CustomMiddleware/ServiceDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.ServiceModel; 6 | using System.Threading.Tasks; 7 | 8 | namespace CustomMiddleware 9 | { 10 | public class ServiceDescription 11 | { 12 | public Type ServiceType { get; private set; } 13 | public IEnumerable Contracts { get; private set; } 14 | public IEnumerable Operations => Contracts.SelectMany(c => c.Operations); 15 | 16 | public ServiceDescription(Type serviceType) 17 | { 18 | ServiceType = serviceType; 19 | 20 | var contracts = new List(); 21 | 22 | foreach (var contractType in ServiceType.GetInterfaces()) 23 | { 24 | foreach (var serviceContract in contractType.GetTypeInfo().GetCustomAttributes()) 25 | { 26 | contracts.Add(new ContractDescription(this, contractType, serviceContract)); 27 | } 28 | } 29 | 30 | Contracts = contracts; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SOAPService/src/CustomMiddleware/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | 4 | "dependencies": { 5 | "NETStandard.Library": "1.6.0", 6 | "System.ServiceModel.Primitives": "4.1.0", 7 | "System.Reflection.TypeExtensions": "4.1.0", 8 | "System.ComponentModel": "4.0.1", 9 | "Microsoft.AspNetCore.Http.Abstractions": "1.0.0" 10 | }, 11 | 12 | "frameworks": { 13 | "netstandard1.6": { 14 | "imports": "dnxcore50" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPClient/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.ServiceModel; 5 | using System.ServiceModel.Channels; 6 | using System.Threading.Tasks; 7 | 8 | namespace SOAPClient 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | Random numGen = new Random(); 15 | double x = numGen.NextDouble() * 20; 16 | double y = numGen.NextDouble() * 20; 17 | 18 | var serviceAddress = "http://localhost:5000/CalculatorService.svc"; 19 | 20 | var client = new CalculatorServiceClient(new BasicHttpBinding(), new EndpointAddress(serviceAddress)); 21 | Console.WriteLine($"{x} + {y} == {client.Add(x, y)}"); 22 | Console.WriteLine($"{x} - {y} == {client.Subtract(x, y)}"); 23 | Console.WriteLine($"{x} * {y} == {client.Multiply(x, y)}"); 24 | Console.WriteLine($"{x} / {y} == {client.Divide(x, y)}"); 25 | client.Get("Client"); 26 | } 27 | } 28 | class CalculatorServiceClient : ClientBase 29 | { 30 | public CalculatorServiceClient(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress) { } 31 | public double Add(double x, double y) => Channel.Add(x, y); 32 | public double Subtract(double x, double y) => Channel.Subtract(x, y); 33 | public double Multiply(double x, double y) => Channel.Multiply(x, y); 34 | public double Divide(double x, double y) => Channel.Divide(x, y); 35 | 36 | public void Get(string str) 37 | { 38 | Console.WriteLine(Channel.Get(str)); 39 | } 40 | } 41 | 42 | [ServiceContract] 43 | public interface ICalculatorService 44 | { 45 | [OperationContract] 46 | double Add(double x, double y); 47 | [OperationContract] 48 | double Subtract(double x, double y); 49 | [OperationContract] 50 | double Multiply(double x, double y); 51 | [OperationContract] 52 | double Divide(double x, double y); 53 | [OperationContract] 54 | string Get(string str); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("SOAPClient")] 11 | [assembly: AssemblyTrademark("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("2b13196b-7529-4e79-aa72-9af00f71c459")] 20 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPClient/SOAPClient.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 10 | 2b13196b-7529-4e79-aa72-9af00f71c459 11 | SOAPClient 12 | .\obj 13 | .\bin\ 14 | v4.5.2 15 | 16 | 17 | 18 | 2.0 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPClient/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "Microsoft.NETCore.App": { 9 | "type": "platform", 10 | "version": "1.0.0" 11 | }, 12 | "System.Private.ServiceModel": "4.1.0", 13 | "System.ServiceModel.Http": "4.1.0", 14 | "System.ServiceModel.Primitives": "4.1.0" 15 | }, 16 | 17 | "frameworks": { 18 | "netcoreapp1.0": { 19 | "imports": "dnxcore50" 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/CalculatorService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.ServiceModel; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOAPService 8 | { 9 | public class CalculatorService : ICalculatorService 10 | { 11 | public double Add(double x, double y) => x + y; 12 | public double Divide(double x, double y) => x / y; 13 | public double Multiply(double x, double y) => x * y; 14 | public double Subtract(double x, double y) => x - y; 15 | public string Get(string str) => $"{str} Hello World!"; 16 | } 17 | 18 | [ServiceContract] 19 | public interface ICalculatorService 20 | { 21 | [OperationContract] 22 | double Add(double x, double y); 23 | [OperationContract] 24 | double Subtract(double x, double y); 25 | [OperationContract] 26 | double Multiply(double x, double y); 27 | [OperationContract] 28 | double Divide(double x, double y); 29 | 30 | [OperationContract] 31 | string Get(string str); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 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 SOAPService.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | public class ValuesController : Controller 11 | { 12 | // GET api/values 13 | [HttpGet] 14 | public IEnumerable 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 | } 45 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/Program.cs: -------------------------------------------------------------------------------- 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.Hosting; 7 | using Microsoft.AspNetCore.Builder; 8 | 9 | namespace SOAPService 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() 20 | .Build(); 21 | 22 | host.Run(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4689/", 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 | "SOAPService": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "launchUrl": "http://localhost:5000/api/values", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/SOAPService.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 3ddf128c-8e5a-4222-8aa3-9808ba4ca880 10 | SOAPService 11 | .\obj 12 | .\bin\ 13 | v4.5.2 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.ServiceModel; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.DependencyInjection; 10 | using Microsoft.Extensions.Logging; 11 | using CustomMiddleware; 12 | 13 | namespace SOAPService 14 | { 15 | public class Startup 16 | { 17 | public Startup(IHostingEnvironment env) 18 | { 19 | var builder = new ConfigurationBuilder() 20 | .SetBasePath(env.ContentRootPath) 21 | .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) 22 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) 23 | .AddEnvironmentVariables(); 24 | Configuration = builder.Build(); 25 | } 26 | 27 | public IConfigurationRoot Configuration { get; } 28 | 29 | // This method gets called by the runtime. Use this method to add services to the container. 30 | public void ConfigureServices(IServiceCollection services) 31 | { 32 | // Add framework services. 33 | services.AddMvc(); 34 | services.AddScoped(); 35 | } 36 | 37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 38 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 39 | { 40 | loggerFactory.AddConsole(Configuration.GetSection("Logging")); 41 | loggerFactory.AddDebug(); 42 | //加入一个/CalculatorService.svc 地址,绑定Http 43 | app.UseSOAPMiddleware("/CalculatorService.svc", new BasicHttpBinding()); 44 | 45 | app.UseMvc(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.App": { 4 | "version": "1.0.0", 5 | "type": "platform" 6 | }, 7 | "Microsoft.AspNetCore.Mvc": "1.0.0", 8 | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 9 | "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", 10 | "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 11 | "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", 12 | "Microsoft.Extensions.Configuration.Json": "1.0.0", 13 | "Microsoft.Extensions.Logging": "1.0.0", 14 | "Microsoft.Extensions.Logging.Console": "1.0.0", 15 | "Microsoft.Extensions.Logging.Debug": "1.0.0", 16 | "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", 17 | "CustomMiddleware": "1.0.0-*", 18 | "System.ServiceModel.Http": "4.1.0" 19 | }, 20 | 21 | "tools": { 22 | "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" 23 | }, 24 | 25 | "frameworks": { 26 | "netcoreapp1.0": { 27 | "imports": [ 28 | "dotnet5.6", 29 | "portable-net45+win8" 30 | ] 31 | } 32 | }, 33 | 34 | "buildOptions": { 35 | "emitEntryPoint": true, 36 | "preserveCompilationContext": true 37 | }, 38 | 39 | "runtimeOptions": { 40 | "configProperties": { 41 | "System.GC.Server": true 42 | } 43 | }, 44 | 45 | "publishOptions": { 46 | "include": [ 47 | "wwwroot", 48 | "Views", 49 | "Areas/**/Views", 50 | "appsettings.json", 51 | "web.config" 52 | ] 53 | }, 54 | 55 | "scripts": { 56 | "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /SOAPService/src/SOAPService/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /gRPCDemo/README.md: -------------------------------------------------------------------------------- 1 | #gRPCDemo 2 | 3 | [gRPC C#学习](http://www.cnblogs.com/linezero/p/grpc.html) -------------------------------------------------------------------------------- /gRPCDemo/gRPCClient/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCClient/Program.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using GRPCDemo; 8 | 9 | namespace gRPCClient 10 | { 11 | class Program 12 | { 13 | static void Main(string[] args) 14 | { 15 | Channel channel = new Channel("127.0.0.1:9007", ChannelCredentials.Insecure); 16 | 17 | var client = new gRPC.gRPCClient(channel); 18 | var reply= client.SayHello(new HelloRequest { Name = "LineZero" }); 19 | Console.WriteLine("来自" + reply.Message); 20 | 21 | channel.ShutdownAsync().Wait(); 22 | Console.WriteLine("任意键退出..."); 23 | Console.ReadKey(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("gRPCClient")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("gRPCClient")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("2b0239a8-772f-486f-8aa6-113a561af934")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCClient/gRPCClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2B0239A8-772F-486F-8AA6-113A561AF934} 8 | Exe 9 | Properties 10 | gRPCClient 11 | gRPCClient 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll 40 | True 41 | 42 | 43 | ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll 44 | True 45 | 46 | 47 | 48 | 49 | ..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll 50 | True 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | {c391be7d-7209-4dd8-bc30-be70a460ec08} 70 | gRPCDemo 71 | 72 | 73 | 74 | 75 | 76 | 77 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 78 | 79 | 80 | 81 | 88 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCClient/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gRPCDemo", "gRPCDemo\gRPCDemo.csproj", "{C391BE7D-7209-4DD8-BC30-BE70A460EC08}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gRPCServer", "gRPCServer\gRPCServer.csproj", "{5302EDBC-7DE0-431B-A77F-5254C9E50F95}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gRPCClient", "gRPCClient\gRPCClient.csproj", "{2B0239A8-772F-486F-8AA6-113A561AF934}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {5302EDBC-7DE0-431B-A77F-5254C9E50F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {5302EDBC-7DE0-431B-A77F-5254C9E50F95}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {5302EDBC-7DE0-431B-A77F-5254C9E50F95}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {5302EDBC-7DE0-431B-A77F-5254C9E50F95}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2B0239A8-772F-486F-8AA6-113A561AF934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {2B0239A8-772F-486F-8AA6-113A561AF934}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {2B0239A8-772F-486F-8AA6-113A561AF934}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {2B0239A8-772F-486F-8AA6-113A561AF934}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCDemo/HelloworldGrpc.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: helloworld.proto 3 | #region Designer generated code 4 | 5 | using System; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using Grpc.Core; 9 | 10 | namespace GRPCDemo { 11 | public static class gRPC 12 | { 13 | static readonly string __ServiceName = "gRPCDemo.gRPC"; 14 | 15 | static readonly Marshaller __Marshaller_HelloRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::GRPCDemo.HelloRequest.Parser.ParseFrom); 16 | static readonly Marshaller __Marshaller_HelloReply = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::GRPCDemo.HelloReply.Parser.ParseFrom); 17 | 18 | static readonly Method __Method_SayHello = new Method( 19 | MethodType.Unary, 20 | __ServiceName, 21 | "SayHello", 22 | __Marshaller_HelloRequest, 23 | __Marshaller_HelloReply); 24 | 25 | /// Service descriptor 26 | public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor 27 | { 28 | get { return global::GRPCDemo.HelloworldReflection.Descriptor.Services[0]; } 29 | } 30 | 31 | /// Base class for server-side implementations of gRPC 32 | public abstract class gRPCBase 33 | { 34 | public virtual global::System.Threading.Tasks.Task SayHello(global::GRPCDemo.HelloRequest request, ServerCallContext context) 35 | { 36 | throw new RpcException(new Status(StatusCode.Unimplemented, "")); 37 | } 38 | 39 | } 40 | 41 | /// Client for gRPC 42 | public class gRPCClient : ClientBase 43 | { 44 | /// Creates a new client for gRPC 45 | /// The channel to use to make remote calls. 46 | public gRPCClient(Channel channel) : base(channel) 47 | { 48 | } 49 | /// Creates a new client for gRPC that uses a custom CallInvoker. 50 | /// The callInvoker to use to make remote calls. 51 | public gRPCClient(CallInvoker callInvoker) : base(callInvoker) 52 | { 53 | } 54 | /// Protected parameterless constructor to allow creation of test doubles. 55 | protected gRPCClient() : base() 56 | { 57 | } 58 | /// Protected constructor to allow creation of configured clients. 59 | /// The client configuration. 60 | protected gRPCClient(ClientBaseConfiguration configuration) : base(configuration) 61 | { 62 | } 63 | 64 | public virtual global::GRPCDemo.HelloReply SayHello(global::GRPCDemo.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 65 | { 66 | return SayHello(request, new CallOptions(headers, deadline, cancellationToken)); 67 | } 68 | public virtual global::GRPCDemo.HelloReply SayHello(global::GRPCDemo.HelloRequest request, CallOptions options) 69 | { 70 | return CallInvoker.BlockingUnaryCall(__Method_SayHello, null, options, request); 71 | } 72 | public virtual AsyncUnaryCall SayHelloAsync(global::GRPCDemo.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 73 | { 74 | return SayHelloAsync(request, new CallOptions(headers, deadline, cancellationToken)); 75 | } 76 | public virtual AsyncUnaryCall SayHelloAsync(global::GRPCDemo.HelloRequest request, CallOptions options) 77 | { 78 | return CallInvoker.AsyncUnaryCall(__Method_SayHello, null, options, request); 79 | } 80 | protected override gRPCClient NewInstance(ClientBaseConfiguration configuration) 81 | { 82 | return new gRPCClient(configuration); 83 | } 84 | } 85 | 86 | /// Creates service definition that can be registered with a server 87 | public static ServerServiceDefinition BindService(gRPCBase serviceImpl) 88 | { 89 | return ServerServiceDefinition.CreateBuilder() 90 | .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build(); 91 | } 92 | 93 | } 94 | } 95 | #endregion 96 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCDemo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("gRPCDemo")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("gRPCDemo")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("c391be7d-7209-4dd8-bc30-be70a460ec08")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCDemo/gRPCDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08} 8 | Library 9 | Properties 10 | gRPCDemo 11 | gRPCDemo 12 | v4.5.2 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll 37 | True 38 | 39 | 40 | ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll 41 | True 42 | 43 | 44 | 45 | 46 | ..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll 47 | True 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 70 | 71 | 72 | 73 | 80 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCDemo/helloworld.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package gRPCDemo; 3 | service gRPC { 4 | rpc SayHello (HelloRequest) returns (HelloReply) {} 5 | } 6 | 7 | message HelloRequest { 8 | string name = 1; 9 | } 10 | 11 | message HelloReply { 12 | string message = 1; 13 | } -------------------------------------------------------------------------------- /gRPCDemo/gRPCDemo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCServer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCServer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using GRPCDemo; 7 | using Grpc.Core; 8 | 9 | namespace gRPCServer 10 | { 11 | class gRPCImpl : gRPC.gRPCBase 12 | { 13 | // 实现SayHello方法 14 | public override Task SayHello(HelloRequest request, ServerCallContext context) 15 | { 16 | return Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); 17 | } 18 | } 19 | 20 | class Program 21 | { 22 | const int Port = 9007; 23 | 24 | public static void Main(string[] args) 25 | { 26 | Server server = new Server 27 | { 28 | Services = { gRPC.BindService(new gRPCImpl()) }, 29 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } 30 | }; 31 | server.Start(); 32 | 33 | Console.WriteLine("gRPC server listening on port " + Port); 34 | Console.WriteLine("任意键退出..."); 35 | Console.ReadKey(); 36 | 37 | server.ShutdownAsync().Wait(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("gRPCServer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("gRPCServer")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("5302edbc-7de0-431b-a77f-5254c9e50f95")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /gRPCDemo/gRPCServer/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /gRPCDemo/generate.txt: -------------------------------------------------------------------------------- 1 | packages\Grpc.Tools.1.0.0\tools\windows_x86\protoc.exe -IgRPCDemo --csharp_out gRPCDemo gRPCDemo\helloworld.proto --grpc_out gRPCDemo --plugin=protoc-gen-grpc=packages\Grpc.Tools.1.0.0\tools\windows_x86\grpc_csharp_plugin.exe 2 | 3 | --------------------------------------------------------------------------------