Page Nav

SHOW

Grid

GRID_STYLE

Hover Effects

TRUE

Pages

Latest Tech Updates

latest

Session Management in MVC

In web programming some time we want to make the value persistance among differnet request to do this In MVC we have different mechanisim ...

In web programming some time we want to make the value persistance among differnet request to do this
In MVC we have different mechanisim to maintain the session, these are :-

-- Viewbag.
-- Viewdata.
-- Tempdata.

Viewbag :-
 In MVC Viewbag is class which allow the programmer maintain data persistance among the request.

Using of Viewbag has some limitation these are :-

Viewbag can only used for single request , it means it make the value persistence if the request made for the first time to that page once the request completed viewbag data become null. So it use full to used with in page. Viewbag is a dynamic type.

How to use viewbag programmatically :-

Viewbag.data="Mydata";

and when we want to access we can access it by following way :-
@Viewbag.data