I am trying to pass a the number of products that are added to the shopping card
it needs to show in the _loginPartial.cshtml Top header bar
but it seems more complicated than i thought
- @{
- var userid = HttpContext.Request.Cookies["Shopping-card"];
- string getcount = _context.shoppingCard.Where(x => x.ClientId == Guid.Parse(userid)).Count().ToString();
- }
- class
-
- class
="nav-item"> - class="nav-link text-dark" asp-controller="Home" asp-action="Checkout"> Shoppingcard @getcount
Im getting a error on the "HttpContext"
so i tried to create a function in the controller and then pass it into the _loginPartial.cshtml
- public string getShoppingbackcount()
- {
- var userid = HttpContext.Request.Cookies["Shopping-card"];
- string getcount = _context.shoppingCard.Where(x => x.ClientId == Guid.Parse(userid)).Count().ToString();
- return getcount;
- }
That did not work either. even when i use the @using Webshop.Controllers;
im getting allot of error saying that "getShoppingbackcount()" does not exist
I am out of ideas to get database date passed to the _loginPartial.cshtml
Satya KarkiPosted Apr 22, 2021, 3:10 PM
osyris zosarPosted Apr 22, 2021, 2:15 PM
class
="navbar-nav">Aarti GuptaPosted Apr 22, 2021, 7:29 AM
Asma KhalidPosted Apr 22, 2021, 7:21 AM
Satya KarkiPosted Apr 22, 2021, 5:39 AM