Поскольку я разместил свое приложение на облачном сервере plesk, и все в порядке, но если я в идеале сижу на экране в течение 10 минут, то он покажет ошибку Ошибка произошла во время операции шифрования c.
Я не понял, почему он показывает ошибку, пожалуйста, помогите мне. Вот мой код global.ashx и код контроллера. Я пытался все еще не может найти решение
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
{
//HttpCookie authCookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
HttpCookie authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null)
{
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
LoginUserViewModel serializeModel = JsonConvert.DeserializeObject<LoginUserViewModel>(authTicket.UserData);
CustomPrincipal newUser = new CustomPrincipal(authTicket.Name);
newUser.Id = serializeModel.Id;
newUser.Email = serializeModel.Email;
//newUser.Password = serializeModel.Password;
newUser.FullName = serializeModel.FullName;
newUser.FirstName = serializeModel.FirstName;
newUser.LastName = serializeModel.LastName;
newUser.Roles = serializeModel.Roles;
HttpContext.Current.User = newUser;
}
}
namespace WebApp.Controllers
{
public class AccountController : Controller
{
// GET: Account
IUserRepository repo_user;
public AccountController(IUserRepository _repo_user)
{
repo_user = _repo_user;
}
public ActionResult Login()
{
return View();
}
public ActionResult UnAuthorize()
{
return View();
}
[HttpPost]
public ActionResult Login(LoginViewModel model)
{
if (ModelState.IsValid)
{
//UserViewModel user = repo_user.ValidateUser(model);
LoginUserViewModel user = repo_user.ValidateUser(model);
if (user != null)
{
string data = JsonConvert.SerializeObject(user);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.Email, DateTime.Now, DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes), false, data, FormsAuthentication.FormsCookiePath);
string encTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
Response.Cookies.Add(cookie);
if (user.Roles.Contains("Admin"))
{
return RedirectToAction("Index", "Home", new { area = "Admin" });
}
else if (user.Roles.Contains("Company"))
{
return RedirectToAction("Index", "Home", new { area = "Company" });
}
else if (user.Roles.Contains("User"))
{
return RedirectToAction("Index", "Home", new { area = "User" });
}
else if (user.Roles.Contains("Franchisee"))
{
return RedirectToAction("Index", "Home", new { area = "Franchisee" });
}
}
else
{
TempData["UserLogin"] = " Userid or Password does not exist, please try with other credential";
}
}
return View();
}
public ActionResult SignOut()
{
FormsAuthentication.SignOut();
return RedirectToAction("Login");
}
}
}