Don't get session value in angularjs file

I want to get asp.net (C #) session value in angularjs file , which should be the best way to access session value.

That I tried but couldn't get it.

 $session.get(key) 

      

+3


source to share


2 answers


ASP.NET is the backend and Angular runs in the browser .; -)

You have several options:



  • write the session to a cookie (if not already done by ASP.NET) and read the value through the angular-cookies library

  • write a RESTful service to get the session information value

  • output value to hidden field and read it through jquery

+3


source


You need to do this through the server controller, the session is stored on the server and angular will be executed on the client. This way you can force the session controller to get the key and return the value from the session in JSOn format.



+1


source







All Articles