Я не знаю, почему HttpRuntime.Cache[this.User.Identity.Name]
очищает при использовании File.WriteAllBytes
Мой код
CurrentUserInfo currentUserInfo = (CurrentUserInfo)HttpRuntime.Cache[this.User.Identity.Name];
var content = await Request.Content.ReadAsByteArrayAsync();
currentUserInfo = (CurrentUserInfo)HttpRuntime.Cache[this.User.Identity.Name];
string filePath = HttpContext.Current.Server.MapPath($"~/bin/InsuranceFile/1");
if (!Directory.Exists(filePath))
Directory.CreateDirectory(filePath);
File.WriteAllBytes(filePath+$"/{Path.GetRandomFileName()}", content)