Reputation: 3706
I want to access asp.net(C#) session value in angularjs file, what should be the best way to access session value.
What i tried, but couldn't able to get it.
$session.get(key)
Upvotes: 3
Views: 2144
Reputation: 622
Expanding on Michael's 2nd option "write a RESTful service to get some session information value"
One possible way to do this is
Upvotes: 0
Reputation: 3774
You need to do this through a server side controller, the session is stored on the server, while angular will run on the client. So you can make a Session controller to receive a key and to return in JSOn format the value from the Session.
Upvotes: 1
Reputation: 3104
ASP.NET is backend and Angular runs in the browser. ;-)
You have several options:
write the session into a cookie (if not already done by ASP.NET) and read the value via the angular-cookies library
write a RESTful service to get some session information value
render the value into a hidden field and read it via jquery
Upvotes: 3