ASP.NET_SessionId

Larissa Pereira 1 Reputation point
2021-09-20T11:15:42.687+00:00

i want to secure 'ASP.NET_SessionId' cookie, so i added

<httpCookies httpOnlyCookies="true" requireSSL="true"/> to web.config and

Response.Cookies[ASP.NET_SessionId].Secure = true; to master page.

However when i add code to master page my session gets lost.
Need help

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,199 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,281 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,036 Reputation points Microsoft Vendor
    2021-09-21T03:15:39.787+00:00

    Hi @Larissa Pereira

    Try to set the Response.Cookies ["ASP.NET_SessionID"].Secure = true in the Session_Start of the global.asax instead of master page.

    133786-capture.png


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.