Reply to thread

i am working on a shopping cart for a project and i'm really stuck. ASP.NET seams to be really hard :(

I get this error

Unable to cast object of type 'System.String' to type 'System.Collections.Generic.List`1[System.String]'.

At this line of code

var values = (List<string>)Session["Cart"];

Any help would be nice!

if (Session["Cart"] == null)

        {

            Response.Redirect("Products.aspx", false);

        }

   

        {

            var values = (List<string>)Session["Cart"];

            if (values.Count <= 0)

            {

                Response.Redirect("Products.aspx", false);

            }

        }

This error only happens if i have 1 item only in the cart


Loading…
Back
Top