TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Madhav Sharma
880
899
39.2k
Getting "Error occurred during a cryptographic operation"
Apr 9 2020 3:19 AM
As I hosted my application in plesk cloud server and everything is fine but if I sit screen ideally for 10 min then it will show the error
Error occurred during a cryptographic operation.
I did not understand why it is showing error, please help me.
Here is my global.ashx file code and controller code
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
(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"
);
}
}
}
Reply
Answers (
2
)
Post login data to extenal web api without using ajax jquery
Partial page update