小编Rea*_*ath的帖子

IIS 中的 RSA 容器返回“对象已存在”

当我将我的工作ASP.NET CORE 2.2应用程序部署到我的本地 IIS 10 时,它给了我异常

Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Object already exists
   at Internal.NativeCrypto.CapiHelper.CreateCSP(CspParameters parameters, Boolean randomKeyContainer, SafeProvHandle& safeProvHandle)
   at Internal.NativeCrypto.CapiHelper.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
   at System.Security.Cryptography.RSACryptoServiceProvider.get_SafeProvHandle()
   at System.Security.Cryptography.RSACryptoServiceProvider.get_SafeKeyHandle()
   at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 keySize, CspParameters parameters, Boolean useDefaultKeySize)
   at System.Security.Cryptography.RSACryptoServiceProvider..ctor(CspParameters parameters)
   at SamoletBot.Utilities.RSAHelper.GetRSAFromString(String pemstr) in D:\Projects\SamoletBot22\SamoletBot\SamoletBot.Utilities\RSAHelper.cs:line 23
Run Code Online (Sandbox Code Playgroud)

这是相关的代码:

   CspParameters cspParameters = new CspParameters();
   cspParameters.KeyContainerName = "TheContainer";
   cspParameters.Flags = CspProviderFlags.UseMachineKeyStore;

   RSACryptoServiceProvider rsaKey;
   rsaKey = new RSACryptoServiceProvider(cspParameters);
Run Code Online (Sandbox Code Playgroud)

在最后一行抛出异常

阅读后我得出结论,这是由于 RSA 容器权限而发生的,我看到了几个答案,它们使用它来向每个用户授予权限。

CryptoKeyAccessRule rule = new CryptoKeyAccessRule("everyone", CryptoKeyRights.FullControl, AccessControlType.Allow);
Run Code Online (Sandbox Code Playgroud)

问题是CryptoKeyAccessRule找不到。我已经进口了using System.Security.AccessControl。查看Microsoft …

c# iis rsa asp.net-core

7
推荐指数
1
解决办法
396
查看次数

Ef Core 3 .GroupBy() 按日期选择每组之一

基本上我想做与这里相同的事情: https: //stackoverflow.com/a/16274992/4138686,但是在 EF Core 3.1.3 中使用这个答案给了我

System.InvalidOperationException: LINQ 表达式 '(GroupByShaperExpression: KeySelector: (r.Price), ElementSelector:(EntityShaperExpression: EntityType: RetailerRate ValueBufferExpression: (ProjectionBindingExpression: EmptyProjectionMember) IsNullable: False ) ) .OrderByDescending(r => r.CreatedAt)'无法翻译。以可翻译的形式重写查询,或者通过插入对 AsEnumerable()、AsAsyncEnumerable()、ToList() 或 ToListAsync() 的调用来显式切换到客户端计算。有关详细信息,请参阅https://go.microsoft.com/fwlink/?linkid=2101038 。

这是代码:

await _db.RetailerRates
                .GroupBy(r => r.Price)
                .Select(g => g.OrderByDescending(r => r.CreatedAt).First())
                .ToListAsync();
Run Code Online (Sandbox Code Playgroud)

有没有办法根据 EF Core 3.1 中每个组的日期检索第一个元素?

c# group-by ef-core-3.1

6
推荐指数
0
解决办法
4654
查看次数

使用计算属性名称作为导出函数名称

我知道您可以执行以下操作:

let name = 'testFunc'
let functions = {
  [name] () {...}
}
Run Code Online (Sandbox Code Playgroud)

但是否可以做这样的事情:

export function [name] () {...}

javascript ecmascript-6

4
推荐指数
1
解决办法
430
查看次数

BitStamp错误:"仅POST端点"无法识别我的发布请求

我不确定这个问题是否属于SO,首先我认为这是我的代码中的一个问题,但后来我尝试了Postman并得到了相同的错误响应.我正在尝试使用Bitstamp API执行买单(或卖出,它是相同的),但API返回"POST Only Endpoint",但我100%肯定request.Method = "POST".我已经实现了帐户余额 API调用,这也是POST,一切都很好.但对于一些人来说,我无法让买/卖API调用工作.

以下是一些图片,证明我确实正在发送POST请求,之后是POSTMAN的图片.有人有这个问题吗? 码

邮差

httpwebrequest postman

2
推荐指数
1
解决办法
333
查看次数

HangFire 无法排队(即发即忘)作业

我有一个长时间运行的方法,我决定使用 HangFire 在后台执行并通过仪表板管理它们。我使用以下代码设置了仪表板和 Hangfire 本身:

HangFireConfiguration.cs

public static class HangFireConfiguration
{
    public static string DashboardUrl = "/tasks";

    public static void Configure(IAppBuilder app)
    {
        GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection");

        var options = new DashboardOptions
        {
            Authorization = new[]
            {
                new HangFireAuthorization()
            }
        };

        app.UseHangfireDashboard(DashboardUrl, options);
        app.UseHangfireServer(new BackgroundJobServerOptions()
        {
            //ShutdownTimeout = TimeSpan.FromHours(24)
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

HangFireAuthorization.cs

public class HangFireAuthorization : IDashboardAuthorizationFilter
{
    public static string DashboardUrl = "/tasks";

    public bool Authorize([NotNull] DashboardContext context)
    {
        if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
        {
            return HttpContext.Current.User.IsInRole("admin");
        }
        return false; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc asp.net-mvc-5 hangfire

2
推荐指数
1
解决办法
5366
查看次数