0

I have two applications. One is the User interface, that stores information like UserID on the session. The other is a web api that communicate with the UI. I need to share this UI session with web api.

1- I know that is not recommended to use session with Web Api, but for my purpose I need to do it.

2- I´m using sessionState mode="SQLServer" because of web farm.

<sessionState mode="SQLServer" sqlConnectionString="Server=servername;Database=dbname;User ID=username;Password=password;Application Name=name;" cookieless="false" allowCustomSqlDatabase="true" timeout="20"/>

<machineKey validationKey="SomeKey" decryptionKey="somekey" validation="SHA1" decryption="AES" />

both applications have the same configuration, but for some reason that i don´t know, it is not doing right.

3 - i´m still developping it locally.

Can someone help me?

Ivo Queiroz
  • 21
  • 1
  • 8
  • i never tried use sql sessionstate, i used to use session server. that will be more easier. – Ray H Sep 28 '17 at 00:46
  • in my case I must use sql sessionstate @RayH – Ivo Queiroz Sep 28 '17 at 12:04
  • what do you mean by this? "The other is a web api that communicate with the UI". Does UI invokes web API to fetch information? – Rex Sep 28 '17 at 13:04
  • @Rex UI invokes web api to save some data into database – Ivo Queiroz Sep 28 '17 at 13:38
  • then you may need to use token based authorization. Pass the token in header when wepapi request is invoked and retrieve the session stored in database with in webapi using token. Possibly this only is the only way to share session between 2 apps. – Rex Sep 28 '17 at 13:41
  • @Rex Ok, so i need to send this token in the http request header. But what token is it? What do you suggest me to do to send this token? – Ivo Queiroz Sep 28 '17 at 13:54
  • Token could be a GUID issued to each user issued for respective successful login. This can be anything that should be unique per user/login(database identity as well). You store this token in cookie or session and as well as database along with session and then pass this token to webapi (either accessing it from cookie or session from UI). – Rex Sep 28 '17 at 14:25

0 Answers0