I'm trying to obtain the value of a cookie, and based on that display different links in the navbar on top of my page. This is an ASP.NET Core MVC 3.1 application. I'm getting an error that the word Request
is not valid in this context. Is there a way to get that code working, or is different code needed to get that value? In my startup file, I have the code: app.UseCookiePolicy();
<li class="nav-item">
@{string signedUp = Request.Cookies["signedUp"]; }
@*if user's first time, show signup link, otherwise, then the if else below...*@
@if (User.Identity.IsAuthenticated)
{
<a class="nav-link text-dark" asp-area="" asp-controller="Account" asp-action="LogOut">Log Out</a>
}
else
{
<a class="nav-link text-dark" asp-area="" asp-controller="Account" asp-action="LogIn">Log In</a>
}
</li>
The razor page has the HttpContext
and the Request
is the part of the Context
:
@{ string signedUp = Context.Request.Cookies["signedUp"]; }
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httpcontext.request