Problem:
I am trying to assign a value to a session object in MVC Controller, it provides an exception as the Object reference is not installed in the object instance.
I have two controllers
- Maincontroller
- SecondaryController
When I assign a value to a session in the Main controller, it works fine.but, if I assign the same value to the Test () method in the secondary controller, it gives an error.
What am I doing wrong here?
Main controller:
public class MainController: Controller { SecondaryController secCont=new SecondaryController(); public ActionResult Index(LoginModel loginModel) { if (ModelState.IsValid) { Session["LogID"] = 10;
Secondary controller:
public class SecondaryController: Controller { public void Test() { Session["LogID"] = 10;
Vishal i patil
source share