Access Session variables in JavaScript

前端 未结 4 688
北海茫月
北海茫月 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 21:06

    You can do it this way for a String variable:

    
    

    Or like this if it's numeric:

    
    

    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.

提交回复
热议问题