Nimesh khatri
Nimesh khatri

Reputation: 763

how to set session variables globally in web api controller?

i want to set session variables from web api controller and access it into App.js method is there any way to access like that ?

i'd already tried using :-

HttpContext.Current.Session

but i'm not able to set and access session variables globally and access it on second page ...

Upvotes: 0

Views: 3483

Answers (1)

zapoo
zapoo

Reputation: 1589

There is no session mechanisim on web api beacuse it is against restfull idea.

If you need to store data like session you may consider to use

  1. Http Cookies http://www.asp.net/web-api/overview/advanced/http-cookies

  2. Encrypted tokens which has the information you want to store.

  3. Use an MVC application like web api (playing with routes)

    Don't store sensitive data and use HTTPS

Upvotes: 1

Related Questions