|
|
@ -5,13 +5,13 @@ using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages; |
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
|
|
|
|
|
|
|
namespace StateJobsNYSubmit.Pages |
|
|
|
namespace StateJobsNYSubmit.Pages |
|
|
|
{ |
|
|
|
{ |
|
|
|
public class IndexModel : PageModel |
|
|
|
public class IndexModel : PageModel |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly ILogger<IndexModel> _logger; |
|
|
|
private readonly ILogger<IndexModel> _logger; |
|
|
|
public int counter = 1; |
|
|
|
|
|
|
|
private PrivateData p = new PrivateData(); |
|
|
|
private PrivateData p = new PrivateData(); |
|
|
|
public IndexModel(ILogger<IndexModel> logger) |
|
|
|
public IndexModel(ILogger<IndexModel> logger) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -20,14 +20,16 @@ namespace StateJobsNYSubmit.Pages |
|
|
|
|
|
|
|
|
|
|
|
public void OnGet() |
|
|
|
public void OnGet() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
UserData userData = new UserData(); |
|
|
|
|
|
|
|
userData.visitCounter = 1; |
|
|
|
string cookieValue = Request.Cookies["PrivateData"]; |
|
|
|
string cookieValue = Request.Cookies["PrivateData"]; |
|
|
|
if (cookieValue != null) { |
|
|
|
if (cookieValue != null) { |
|
|
|
string test = p.DecryptString(cookieValue); |
|
|
|
string test = p.DecryptString(cookieValue); |
|
|
|
counter = Int32.Parse(test); |
|
|
|
userData = JsonConvert.DeserializeObject<UserData>(test); |
|
|
|
counter++; |
|
|
|
userData.visitCounter++; |
|
|
|
} |
|
|
|
} |
|
|
|
Response.Cookies.Append("PrivateData", p.EncryptString($"{counter}")); |
|
|
|
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData))); |
|
|
|
Console.WriteLine($"Value of counter: {counter}"); |
|
|
|
Console.WriteLine($"Value of counter: {userData.visitCounter}"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|