Access Session variables in JavaScript

前端 未结 4 680
北海茫月
北海茫月 2021-01-04 20:44

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 wa

4条回答
  •  离开以前
    2021-01-04 20:59

    For google searchers,

    In addition, If you want to access the session variable in external .js file you can simply do like this,

    ------ SOME HTML PAGE ------
    
    //Scripts below Html page
    
    
    // Load External Javascript file
     
    

    Inside NewFile.js

    $(document).ready(function () {
        alert(mySessionVariable);
    });
    

提交回复
热议问题