👻 Elektrikli Erol👻
❔ ASP.NET to .net Core
Im trying to convert my asp.net project to .net core. I have a class thats using Httpcontext in some getter functions. I cant convert this class to .net core class. Can you help me ?
public static User CurrentUser { get { var ck = HttpContext.Request.Cookies[TOKEN_COOKIE_NAME]; Guid token; if (ck != null && Guid.TryParse(ck.Value, out token)) { var key = "BlueCMSUser" + token; if (HttpContext.Current.Cache[key] == null) { var user = User.GetByToken(token); if (user != null) { HttpContext.Current.Cache.Add(key, user, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(15), System.Web.Caching.CacheItemPriority.Default, null); } else { RemoveToken(); } } return HttpContext.Current.Cache[key] as User; } return null; } set { var ck = HttpContext.Current.Request.Cookies[TOKEN_COOKIE_NAME]; Guid token; if (ck != null && Guid.TryParse(ck.Value, out token)) { var key = "CMSUser" + token; HttpContext.Current.Cache[key] = value; } } } this is the code im trying to convert
public static User CurrentUser { get { var ck = HttpContext.Request.Cookies[TOKEN_COOKIE_NAME]; Guid token; if (ck != null && Guid.TryParse(ck.Value, out token)) { var key = "BlueCMSUser" + token; if (HttpContext.Current.Cache[key] == null) { var user = User.GetByToken(token); if (user != null) { HttpContext.Current.Cache.Add(key, user, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(15), System.Web.Caching.CacheItemPriority.Default, null); } else { RemoveToken(); } } return HttpContext.Current.Cache[key] as User; } return null; } set { var ck = HttpContext.Current.Request.Cookies[TOKEN_COOKIE_NAME]; Guid token; if (ck != null && Guid.TryParse(ck.Value, out token)) { var key = "CMSUser" + token; HttpContext.Current.Cache[key] = value; } } } this is the code im trying to convert
29 replies
❔ ASP.NET 4.6.1 project with EF 6.4.4 is very slow on the first query to database ..
I have ASP.NET 4.6.1 project with entity framework 6.4.4, my first query to database after launching the project takes 4seconds but after the first query queries take like 20ms.
why is it happening ? any way to diagnose the problem ?
3 replies