Dip
Dip

Reputation: 877

How to use Session in Asp.Net MVC3

I wants to create session in my project.

i want to know the information about session,its syntax, and method to create it.

first i searched it in google and other websites but no any basic solution found.

so does anyone tell me how to and where to create session in mvc3 Asp.Net C#.

Thank you in advance.

Upvotes: 0

Views: 11013

Answers (1)

Jayanga
Jayanga

Reputation: 887

If you want to add data to the session you can use

Session["your key"] = your value or object;

to retrieve data you can use

var Val = Session["your key"];

if you want to store and get strongly typed objects you can add them in the same way and just cast them when you receive

Session["your key"] = new YourObject();

YourObject obj = (YourObject)Session["your key"] ;

Upvotes: 9

Related Questions