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
Adalat Khan
652
1.5k
866.8k
Session in JavaScript
Jul 28 2019 4:23 AM
I am using MVC Core. In my application i want to set the Session value in JavaScript but it gives me error "Cannot implicitly convert type void to type object". When i get the Session Value then it working properly but when i set value of Session in JavaScript then it gives me the above error. Following is my JavaScript Code:
<script type="text/javascript">
var seconds = @HttpContextAccessor.HttpContext.Session.GetString("SessionSeconds");
var minutes = @HttpContextAccessor.HttpContext.Session.GetString("SessionMinutes");
var hours = @HttpContextAccessor.HttpContext.Session.GetString("SessionHours");
function CountDownSessionTime() {
if (seconds > 0) {
seconds = seconds - 1;
}
else
if (seconds == 0) {
@HttpContextAccessor.HttpContext.Session.SetString("SessionSeconds", "60");
minutes = minutes - 1;
}
}
</script>
The first three lines are working in which i am getting values of Seconds, Minutes, and Hours which i have set in my Controller but in JavaScript i also want to set the value of Seconds in Session but it gives me error. The following line of code give me Error:
@HttpContextAccessor.HttpContext.Session.SetString("SessionSeconds", "60");
The above line give me error "Cannot implicitly convert type void to type object". Please give me an idea how i can set value of Session in JavaScript in MVC Core Application. Thanks
Reply
Answers (
3
)
how to save yes or no as 1 or 0 format using asp c# but user
how to add link from database without create new aspx page?