Apr 16, 2015

[Fixed Solution] : Access C# Session Variables in JavaScript or JQuery

Question : 
I wanted to access a session variable in javascript in asp.net mvc application. I have found a way to do it in aspx view engine but not in razor.
Please tell me a way to access the session variables

Answere:
You can do it this way for a String variable:
<script type="text/javascript">
    var someSessionVariable = '@Session["SomeSessionVariable"]';
</script>
Or like this if it's numeric:
<script type="text/javascript">
    var someSessionVariable = @Session["SomeSessionVariable"];
</script>
This is really not a very clean approach though, and requires inline JavaScript rather than using script files. Be careful not to get carried away with this.

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...