Session Variable for SQL paramater - Private Static RRS feed

  • Question

  • User982203039 posted

    How can I use a session variable in a controller to pass as a parameter for a stored procedure? I have a Public Action result where this works fine, but I can not get it to work on a private static. Do I have any options to get this to work? I am setting the Branch session in the controller.  Below is the code how I am setting the parameter for the Public Action result.


    private static List<Birthdays> GetBirthdays()             
    	var branch = @Session["Branch"];

    Tuesday, August 11, 2020 2:23 PM

All replies

  • User-474980206 posted

    Unless you have only one user, this won’t work. Static are shared across all requests, so if you have two requests at the same time, it can only have one value.

    Tuesday, August 11, 2020 2:36 PM
  • User982203039 posted

    I figured it out.  Thanks!!

    Tuesday, August 11, 2020 2:46 PM