Use standard object/json for User Data
This commit is contained in:
@ -5,13 +5,13 @@ using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace StateJobsNYSubmit.Pages
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
public int counter = 1;
|
||||
private PrivateData p = new PrivateData();
|
||||
public IndexModel(ILogger<IndexModel> logger)
|
||||
{
|
||||
@ -20,14 +20,16 @@ namespace StateJobsNYSubmit.Pages
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
UserData userData = new UserData();
|
||||
userData.visitCounter = 1;
|
||||
string cookieValue = Request.Cookies["PrivateData"];
|
||||
if (cookieValue != null) {
|
||||
string test = p.DecryptString(cookieValue);
|
||||
counter = Int32.Parse(test);
|
||||
counter++;
|
||||
userData = JsonConvert.DeserializeObject<UserData>(test);
|
||||
userData.visitCounter++;
|
||||
}
|
||||
Response.Cookies.Append("PrivateData", p.EncryptString($"{counter}"));
|
||||
Console.WriteLine($"Value of counter: {counter}");
|
||||
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
|
||||
Console.WriteLine($"Value of counter: {userData.visitCounter}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
12
UserData.cs
Normal file
12
UserData.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// UserData myDeserializedClass = JsonConvert.DeserializeObject<UserData>(myJsonResponse);
|
||||
|
||||
using System.Collections.Generic;
|
||||
public class UserData
|
||||
{
|
||||
public string email { get; set; }
|
||||
public string smtpHost { get; set; }
|
||||
public List<string> skillOptions { get; set; }
|
||||
public string identifier { get; set; }
|
||||
public int visitCounter { get; set;}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user