Click here to Skip to main content
15,939,736 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make condition in cshtml view based on userrole that should be in sitemenu class like this.
C#
this.UserRole = userlist[0].UserRole.Tostring();

HttpContext.Session["UserRole"]=this.UserRole;


In view
HTML
<script>

var userRole=@HttpContext.Session["UserRole"].Tostring();

alert(userRole);

</script>

My problem is the session value is not displaying in alert box.

So how to handle this in my page using session. Because that is not controller if I want to use viewBag or ect.
Posted
Updated 12-Sep-14 8:20am
v2

1 solution

Ok i got it

i have removed "@HttpContext" in script block,
and maintained @Session only now it is working fine..
 
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