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
Kapil Bhati
NA
256
133k
Session values goes null in MVC controller
Nov 14 2017 7:08 AM
hi,
I am working with mvc. my code is working fine till last day.But now i am facing an strange problem. I have set a value in Session. Here is code
[code]
public ActionResult RecordForEdit(string ID)
{
int Idd = Convert.ToInt32(ID);
Session["SubuserId"] = Idd;
var model = new SubUserModel();
model.UserName = obd_Sub.LoginId;
model.Pwd = obd_Sub.Password;
model.Status = obd_Sub.Status;
return View("SubUserIndex", model);
}[/code]
then in view a method is called by Jquery .
[code]
public JsonResult GetAssigned_Suburb()
{
string UId ="";
if (Session["SubuserId"] != null)
{
UId = Session["SubuserId"].ToString();
}
var Suburbs = odbe.ODB_GetSuburb_onload(UId);
var jsonResult = Json(Suburbs.ToList(), JsonRequestBehavior.AllowGet);
return jsonResult;
}
[/code]
in this method i get the value of Session["SubuserId"], then again on a button click a method is called.
[code]
public JsonResult GetSuburb_ToAssign(string Pcode, string SubId)
{
string UId = Session["UserId"].ToString();
var UsrId = from s in odbe.ODB_UserMain where s.LoginId == UId select s;
string intId = UsrId.FirstOrDefault().Id.ToString();
string sub_Uid = "0";
if (Session["SubuserId"] != null)
{
sub_Uid = Session["SubuserId"].ToString();
}
var Suburb = odbe.ODB_GetSubuserSuburb_Count(Pcode, intId, sub_Uid);
var jsonResult = Json(Suburb.ToList(), JsonRequestBehavior.AllowGet);
return jsonResult;
}
[/code]
But in this method the method the value of Session["SubuserId"] is null. I not get how it is gone null. I have debug and googled alot but nothing found.
Reply
Answers (
4
)
How to get checkbox id from user control to aspx page
C#---Test project