Click here to Skip to main content
16,019,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some variables and now I want to check for values
exist in session, put them in session on session start in MVC.
I am new to MVC and any help regarding this would be appreciated.

Thanks!
Posted
Comments
Jameel VM 26-Jul-13 10:27am    
Please elaborate your requirement

You can check whether a value is in session by..
C#
if(Session != null && Session["value"] != "yourValue")
{
   // code
}

Where "value" is your session variable or "yourValue" is the value of that variable.

These 2 links will clear you about putting values in a session variable:
http://stackoverflow.com/questions/10123143/asp-net-mvc-3-dealing-with-session-variables[^]
http://stackoverflow.com/questions/560084/session-variables-in-asp-net-mvc[^]

And this tutorial is a must from my point of view:
MVC Test Driven Development: Session Variables[^]
 
Share this answer
 
SQL
if (!string.IsNullOrEmpty(Session["value1"] as string) && !string.IsNullOrEmpty(Session["value2"] as string))            
{
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900