I have an ASP.NET MVC 6 application with a few class libraries (.NET 4.6.1). Now I want to pass the values between the asp.net application and the class libraries. For example I want to access UserId (that is inside a session) from the class library. I don't want to use parameters to pass the value, because UserId is a global variable in my class library and I don't have a reference from web application in the class library. What is the best way to solve this?
- Use Sessions in a class library?
- Use Shared Memory ?
- Use Web Service ?
- Use Dtabase ?
- ... ?
Update : https://stackoverflow.com/a/2040623/2455393 says that we can use this :
using System.Web;
var currentSession = HttpContext.Current.Session;
var myValue = currentSession["myKey"];
in .NET 4.6.1 (MVC 6) it does not work. but in .NET 4.0 it works well. this is my problem.