你写了两个单元测试吗?一种表示值为 Null,另一种表示值为 string.Empty?string.IsNullOrWhiteSpace() 类似?
我有一个Asp.NET MVC应用程序与此身份验证设置:
ConfigureServices():
services.AddSession()
services.AddAuthentication(sharedOptions => sharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme);
Run Code Online (Sandbox Code Playgroud)
配置():
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
ClientId = "xx",
Authority = "xx",
Events = new OpenIdConnectEvents { OnRemoteFailure = this.OnAuthenticationFailed }
});
Run Code Online (Sandbox Code Playgroud)
在IIS中托管时,某些用户会收到此异常:
Microsoft.AspNetCore.Session.SessionMiddleware,
Error unprotecting the session cookie.
System.Security.Cryptography.CryptographicException: The key {9ec59def-874e-45df-9bac-d629f5716a04} was not found in the key ring.
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte[] protectedData, Boolean ignoreRevocationErrors, Boolean& requiresMigration, Boolean& wasRevoked)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
at Microsoft.AspNetCore.Session.CookieProtection.Unprotect(IDataProtector protector, String protectedText, ILogger logger)
Run Code Online (Sandbox Code Playgroud)
我在托管服务器上运行了这个https://github.com/aspnet/DataProtection/blob/dev/Provision-AutoGenKeys.ps1
Web只有HTTPS绑定,SSL证书可以签名.什么可能导致这个问题?究竟是什么"关键"价值?
是否可以在 json 配置文件中传递 Formatter 的构造函数参数?
"WriteTo": [
{
"Name": "Console"
"Args": { "formatter": "Serilog.Formatting.Elasticsearch.ElasticsearchJsonFormatter, Serilog.Formatting.Elasticsearch" }
}
]
Run Code Online (Sandbox Code Playgroud)
正如您在这里看到的,ElasticsearchJsonFormatter ctor 接受一些参数。我想在上面的配置文件中配置它们。
谢谢。
我有一个针对.NET 462的Asp.Net Core项目,它正在使用Asp.Net Core版本1.0.1.升级到"1.1.0"后,我收到此错误:
FileLoadException:无法加载文件或程序集"Microsoft.EntityFrameworkCore.SqlServer,Version = 1.1.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60"或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
project.json
"dependencies": {
"AspNet.Mvc.TypedRouting": "1.2.0",
"AutoMapper": "5.1.1",
"AutoMapper.Extensions.Microsoft.DependencyInjection": "1.1.2",
"BundlerMinifier.Core": "2.2.306",
"JetBrains.Annotations": "10.2.1",
"libphonenumber-csharp": "7.7.4",
"Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
"Microsoft.AspNetCore.Authentication.Facebook": "1.1.0",
"Microsoft.AspNetCore.Authentication.Google": "1.1.0",
"Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0",
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
"Microsoft.AspNetCore.Authentication.Twitter": "1.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0",
"Microsoft.AspNetCore.Session": "1.1.0",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.Extensions.Configuration": "1.1.0",
"Microsoft.Extensions.Configuration.Abstractions": "1.1.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0", …Run Code Online (Sandbox Code Playgroud) 如何在AspNetCore中为StyleCop.Analyzers启用自己的规则集?分析可以使用默认的规则集.
如何在Visual Studio 2017 .NET核心项目中添加对Roslyn Analyzers(.ruleset)的支持?在"project.json"中,它使用buildOptions以下命令配置:
"buildOptions": {
"additionalArguments": [ "/ruleset:rules.ruleset" ]
},
Run Code Online (Sandbox Code Playgroud) 通过让用户使用标准 AAD 登录表单登录,是否可以在 Postman 中获取 AAD 令牌?
我知道如何使用 AAD 请求获取令牌(grant_type = client_credentials),但此类令牌没有 UPN(用户身份)。
我想以某种方式在 Postman 中输入我的凭据并获取令牌。所以这是一个手动交互,用户(我)需要手动登录 - 与 ie 的方式相同。Visual Studio 验证您的身份。
如何根据某些条件将css类应用于网格行(TR)?
我知道我可以将类应用于列而不是整个TR.
asp.net-core ×4
c# ×2
.net ×1
angular ×1
dll ×1
iis ×1
postman ×1
serilog ×1
stylecop ×1
telerik ×1
telerik-grid ×1
unit-testing ×1