Dear All,
I was developing simple login component using Anular 5 and ASP .Net MVC 5 with API Controller.
While creating that functionality I am facing one problem i.e. I am not able to get value of HttpContext.Session object in another component.
Here is my ApiController Code :-
- public class LoginController : ApiController
- {
- private ILoginRepository _loginRepository;
- public LoginController()
- {
- _loginRepository = UnityFactory.ResolveObject();
- }
-
- public HttpResponseMessage Post(string userName,string password)
- {
- string response = _loginRepository.Post(userName, password).ToString();
- if (response.Contains("302"))
- {
- HttpContext.Current.Session.Add("UserName", userName);
- string data = HttpContext.Current.Session["UserName"].ToString();
- }
-
- return Request.CreateResponse(_loginRepository.Post(userName,password));
- }
- }
Please help me in how to send session from ApiController To Angular 5 and vice versa.
Or you can suggest me another option to Session which will be accepted.
Thanking You In Advance.