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
vineet sharma
NA
22
21.6k
how to reterive session value in timer enabled event in mvc
Mar 22 2014 8:25 AM
how to enable session in timer enabled event in mvc 4 using c#
my code:
controller class
public ActionResult Home()
{
DateTime dt = DateTime.Now;
Session["forgotpassworduser"] = null;
Session["securityQuestion"] = null;
if (Session["username"] == null)
{
return RedirectToAction("Login");
}
Email ed = new Email();
var model = ed.receivedMessage(Session["username"].ToString()).ToList();
Timer timer = new Timer();
timer.Interval = (1000) * (10);
timer.Enabled = true;
timer.Elapsed += new ElapsedEventHandler(timer_call);
timer.Start();
return View(model);
}
public ActionResult checkevent(Models.EventCalender ec,string t)
{
if (ec.checkevent(DateTime.Now, t))
{
return RedirectToAction("loadCalender");
}
else
{
string url = this.Request.UrlReferrer.AbsolutePath;
if (url == null)
{
return Redirect(url);
}
}
return View();
}
private void timer_call(object sender, ElapsedEventArgs e)
{
EventCalender ec = new EventCalender();
string t2 = null;
try
{
t2 = Session["username"].ToString();
checkevent(ec, t2);
}
catch (Exception er)
{
string dt = er.ToString();
}
}
error is in this line t2 = Session["username"].ToString();
Reply
Answers (
1
)
Nested listview
ASP.NET MVC 4 or 5.x