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));
- }
- }
Or you can suggest me another option to Session which will be accepted.
Thanking You In Advance.

Siddhartha SharmaRank #2,254 · 626 reputationPosted Mar 20, 2019, 9:07 AM EDT
Siddhartha SharmaRank #2,254 · 626 reputationPosted Mar 20, 2019, 7:38 PM EDT
Mandar ShindeRank #4,584 · 336 reputationPosted Mar 20, 2019, 7:30 PM EDT