更新测试
This commit is contained in:
@@ -13,12 +13,15 @@ using System.IO;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Configuration.Json;
|
using Microsoft.Extensions.Configuration.Json;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace COMCMS.Web.Controllers
|
namespace COMCMS.Web.Controllers
|
||||||
{
|
{
|
||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
public static IConfiguration Configuration { get; set; }
|
public static IConfiguration Configuration { get; set; }
|
||||||
|
public ConcurrentDictionary<string, string> AllSession = new ConcurrentDictionary<string, string>();
|
||||||
public HomeController()
|
public HomeController()
|
||||||
{
|
{
|
||||||
Configuration = new ConfigurationBuilder()
|
Configuration = new ConfigurationBuilder()
|
||||||
@@ -36,6 +39,8 @@ namespace COMCMS.Web.Controllers
|
|||||||
};
|
};
|
||||||
Response.Cookies.Append("abc", "123456", op);//用户名
|
Response.Cookies.Append("abc", "123456", op);//用户名
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,12 +57,7 @@ namespace COMCMS.Web.Controllers
|
|||||||
|
|
||||||
public IActionResult Contact()
|
public IActionResult Contact()
|
||||||
{
|
{
|
||||||
Link l = new Link();
|
Link l = Link.Find(Link._.Id == 1);
|
||||||
l.Title = "心😃💪 💪";
|
|
||||||
l.Sequence = 0;
|
|
||||||
l.IsHide = false;
|
|
||||||
l.LinkURL = "http://www.baidu.com";
|
|
||||||
l.Insert();
|
|
||||||
return View(l);
|
return View(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,24 +114,19 @@ namespace COMCMS.Web.Controllers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region MyRegion
|
||||||
const string SessionKeyName = "_Name";
|
public IActionResult Test3()
|
||||||
const string SessionKeyYearsMember = "_YearsMember";
|
|
||||||
const string SessionKeyDate = "_Date";
|
|
||||||
|
|
||||||
public IActionResult Index3()
|
|
||||||
{
|
{
|
||||||
// Requires using Microsoft.AspNetCore.Http;
|
bool isok = false;
|
||||||
HttpContext.Session.SetString(SessionKeyName, "Rick");
|
if(AllSession.TryAdd(HttpContext.Session.Id, HttpContext.Session.Id))
|
||||||
HttpContext.Session.SetInt32(SessionKeyYearsMember, 3);
|
|
||||||
return RedirectToAction("SessionNameYears");
|
|
||||||
}
|
|
||||||
public IActionResult SessionNameYears()
|
|
||||||
{
|
{
|
||||||
var name = HttpContext.Session.GetString(SessionKeyName);
|
isok = true;
|
||||||
var yearsMember = HttpContext.Session.GetInt32(SessionKeyYearsMember);
|
|
||||||
|
|
||||||
return Content($"Name: \"{name}\", Membership years: \"{yearsMember}\"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Content(isok.ToString() + ":" + JsonConvert.SerializeObject(AllSession));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user