对象序列化成Json:
string jsonString = JsonSerializer.Serialize(weatherForecast);
在服务端获取用户请求的Url地址:
@using Microsoft.AspNetCore.Http.Extensions
@Context.Request.GetEncodedUrl() //Use for any purpose (encoded for safe automation)
@Context.Request.GetDisplayUrl() //Use to display the URL only
在Controller中获取已验证用户ID:
if (user != null && user.Identity.IsAuthenticated)
userId = Convert.ToInt64(user.FindFirst(ClaimTypes.NameIdentifier).Value);