GetCertSN.cshtml.cs 687 B

1234567891011121314151617181920212223242526272829
  1. using Essensoft.Paylinks.Alipay.Core.Utilities;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.AspNetCore.Mvc.RazorPages;
  4. namespace Essensoft.Paylinks.Sample.Web.Pages.Alipay.SecurityTools;
  5. public class GetCertSNModel : PageModel
  6. {
  7. [BindProperty]
  8. public IFormFile Cert { get; set; }
  9. public void OnGet()
  10. {
  11. }
  12. public async Task OnPostAsync()
  13. {
  14. try
  15. {
  16. using var sr = new StreamReader(Cert.OpenReadStream());
  17. var str = await sr.ReadToEndAsync();
  18. ViewData["response"] = AlipayCertUtilities.GetCertSN(str);
  19. }
  20. catch
  21. {
  22. ViewData["response"] = "无法获取";
  23. }
  24. }
  25. }