小编Vin*_*ins的帖子

将私钥转换为 RSACryptoServiceProvider 不起作用

我有一个 X509Certificate2 变量,我正在尝试将该变量的私钥转换为 RSACryptoServiceProvider

RSACryptoServiceProvider pkey = (RSACryptoServiceProvider)cert.PrivateKey;
Run Code Online (Sandbox Code Playgroud)

但是我得到了这个例外。

System.InvalidCastException: '无法将类型为'System.Security.Cryptography.RSACng'的对象转换为类型'System.Security.Cryptography.RSACryptoServiceProvider'。'

发生这种情况很奇怪,因为 SO 中的其他答案提出了与我相同的程序,但我得到了一个例外。有什么解决办法吗?

c# rsa private-key

7
推荐指数
2
解决办法
9473
查看次数

Localdate.format,格式不适用

我的 FXML 中有一个 DatePicker,我需要将它插入到我的 SQL 数据库中的日期。我想格式化我的日期,但它不起作用。

    LocalDate localDate = purchased_at.getValue();
    localDate.format(DateTimeFormatter.ofPattern("dd.mm.yyyy"));
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误。

Caused by: java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: MinuteOfHour
Run Code Online (Sandbox Code Playgroud)

我还是个初学者。在过去的 3 或 4 个月里,我使用了 Java。我正在努力改进。

java javafx date datepicker fxml

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

在添加 ApiController 属性之前,ASP.NET Core 3.1 无法处理 Axios 请求

我有以下问题。每当我向 Api 端点发送内容时,ASP.NET Core 3.1 就无法处理该请求。但是,当我添加该ApiController属性时,它工作得很好。

我的代码是正确的,但只有当我添加此属性时才有效。怎么会这样呢?

作为参考,这是我的代码

应用程序编程接口

[ApiController] //Remove this and the code breaks
[Route("api/SomeApi")]
public class ApiController : Controller {

    private readonly IService service;

    public ApiController(IService service)
    {
        this.service = service;
    }

    [HttpPost]
    [Route("Add")]
    public SomeClass Add(SomeClass foo)
    {
        var userId = service.GetCurrentUserId(User);
        foo.Id = Guid.NewGuid();
        foo.UserId = userId;
        service.Add(foo);
        return foo;
    }
}
Run Code Online (Sandbox Code Playgroud)

JS

axios.post('/api/SomeApi/Add', {
   foo: this.foo,

}).then(function (response: any) {
   this.Id = response.Id;
});
Run Code Online (Sandbox Code Playgroud)

仅供参考,我的 ApiController 上还有其他使用 GET/POST 的方法。GET 方法工作得很好,但 POST 方法仅在我使用查询参数时才有效。在本例中,我没有使用查询参数,因为要发送到 …

javascript ajax model-binding asp.net-core axios

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