0

Session ID changes when sendSmsRandomPass is called from angular side.

I tried solving according to this post and others but to no avail: [https://stackoverflow.com/questions/2874078/asp-net-session-sessionid-changes-between-requests]

Does anyone have any ideas why it doesn't work

    public void sendEmail()
    {
                if (HttpContext.Current.Session != null)
                {
                    HttpContext.Current.Session["phoneSMSForSendPassword"] = 
                   phoneSMSForSendPassword;
                    HttpContext.Current.Session["password"] = password;
                }
                sendSmsRandomPass();

            sendoffice365();
        }



         public void sendSmsRandomPass() {
        if (password == null && phoneSMSForSendPassword == null && 
        HttpContext.Current.Session != null)
        {
            phoneSMSForSendPassword = 
         (string)HttpContext.Current.Session["phoneSMSForSendPassword"];
            password = (string)HttpContext.Current.Session["password"];
        }
       
        SMS.sendSMS(phoneSMSForSendPassword, password );
       
    }
  • It's likely because your Angular clients are not sending the ASP.NET Session cookie (as Angular won't include **any** cookies by default). That said, it's a _code smell_ to depend on Server-side Session State. Also, why are you handling passwords as plaintext? – Dai Dec 22 '21 at 05:25
  • Does this answer your question? [How to send "Cookie" in request header for all the requests in Angular2?](https://stackoverflow.com/questions/35602866/how-to-send-cookie-in-request-header-for-all-the-requests-in-angular2) – Dai Dec 22 '21 at 05:26

0 Answers0