HtmlAgilityPack介绍HtmlAgilityPack是一个专门用来解析Html的库,它可以使用xml的方式来解析html。有人说了,html本身不就是xml?是的,html就是xml,但是html很宽松,没有关闭的节点也可以用,还有一些其他的内容比如js夹杂在里面。如果直接使用xml解析库的话9成会报错的。而HtmlAgilityPack会去处理这些问题,把Html转成一个接近标准的xml来供我们使用。基本用法主要就是doc.LoadHtml(html);这里有个重载是doc.Load(),里面可以直接放url,也可以放Stream。我们这里使用LoadHtml直接加载html内容
上一篇介绍Entity Framework值转换器以及内置值转换器的相关内容。这一篇将介绍如何自定义值转换器。对于使用值转换器的属性,可以按正常方式配置这些层面,并将其应用于转换后的数据库类型。 例如,在将枚举转换为字符串时,可以指定数据库列应为非 Unicode,并且最多可存储20个字符。常规的配置方法如下:protected override void OnModelCreating(ModelBuilder modelBuilder){ modelBuilder .Entity<Rider>() .Property(e => e.Mou
Entity Framework允许使用不同的转换器,在保存和读取数据字段时将存储格式转换为目标对象。使用值转换器可以免去手动变更字段类型,自动实现数据存取的格式转换,为EF的使用带来很大方便。值转换器允许在读取或写入数据库时转换属性值。 此转换可以从一个值转换为同一类型的另一个值 (例如,将字符串) 或从一种类型的值加密为另一种类型的值 (例如,在数据库中将枚举值与字符串相互转换。 )Entity framework值转换器概述值转换器以和的形式指定 ModelClrType ProviderClrType 。 模型类型是实体类型中的属性的 .NET 类型。 提
Newtonsoft.Json在反序列化int的时候默认将空字符串识别为null,抛出异常。在WebApi的传参中是一个极大的困扰。问题就在于int.parse("")会报错。下面是几种常见的数字转换场景:> JsonConvert.DeserializeObject<int>(“4.5”)失败.> JToken.Parse(“4.5”).ToObject<int>()成功并返回4.> JsonConvert.DeserializeObject<uint>(“4.5”)成功并返回4.> JsonConvert.DeserializeO
In support, we’ve been seeing a lot of issues with URL Rewrite in ASP.NET Core. Core is a complete rewrite of .NET and so things have changed. In ASP.NET Core, URL Rewrite is no longer handled by the URL Rewrite module (web.config file) but is now served by URL Rewriting Middleware.This b
JwtSecurityToken:代表一个jwt token,可以直接用此对象生成token字符串,也可以使用token字符串创建此对象SecurityToken:JwtSecurityToken的基类,包含基础数据JwtSecurityTokenHandler:创建、校验token,返回ClaimsPrincipal CanReadToken():确定字符串是否是格式良好的Json Web令牌(JWT) ReadJwtToken(string token):token字符串转为JwtSecurityToken对象 ValidateToken(string token、TokenVali
本文介绍IdentityServer SigningCredential 在product线上的配置。public void ConfigureServices(IServiceCollection services){ .....other code ..... var fileName = Path.Combine(env.WebRootPath, "YOUR_FileName" ); if (!File.Exists(fileName)) { throw new FileNotFound
Unit TestingThe smallest piece of a software that can be testable is called as a Unit. In Object Oriented Programming languages like C# each class is called as a Unit. Testing each such unit independent of others is called as Unit-Testing. Unit Testing is very important in Test Driven Development (T
IdentityServer目前IdentityServer4只支持到dotnetcore core1.1 所以Server必须使用core1.1 。其他项目可以使用core2.0 。 public void ConfigureServices(IServiceCollection services) { //var cert = new X509Certificate2(Path.Combine(_environment.ContentRootPath, "damienbodserver.pfx"), ""); serv
1.Added the below lines In Startup.Configure methodapp.UseOAuthAuthentication(new OAuthOptions() { AuthenticationScheme = "LinkedIn", ClientId = Configuration["Authentication:LinkedIn:ClientID"], ClientSecret = Configuration["Authentication:LinkedIn:ClientSecret"], CallbackPath = new Pat