public async Task <ActionResult> Last() { var notice = await NoticeService.GetAsync(n => n.NoticeStatus == NoticeStatus.Normal, n => n.ModifyDate, false); if (notice == null) { return(ResultData(null, false)); } if (Request.Cookies.TryGetValue("last-notice", out var id) && notice.Id.ToString() == id) { return(ResultData(null, false)); } notice.ViewCount += 1; await NoticeService.SaveChangesAsync(); var dto = notice.Mapper <NoticeDto>(); Response.Cookies.Append("last-notice", dto.Id.ToString(), new CookieOptions() { Expires = DateTime.Now.AddYears(1), SameSite = SameSiteMode.Lax }); return(ResultData(dto)); }