Use
if (HttpContext.Current == null ||
HttpContext.Current.Session == null ||
HttpContext.Current.Session["ShoppingCart"] == null)
instead of
if (Session["ShoppingCart"] == null)
More Related Contents:
- Session Variable with if/else statement in Views?
- Keeping ASP.NET Session Open / Alive
- Web app blocked while processing another web app on sharing same session
- How to set session timeout in web.config
- Advantages of Cache vs Session
- Access HttpContext.Current from different threads
- HttpContext.Current.Session is null in Ashx file
- What is the best way to determine a session variable is null or empty in C#?
- How to delete cookies on an ASP.NET website
- How to Kill A Session or Session ID (ASP.NET/C#)
- How to share sessions between PHP and ASP.net application?
- What is the difference between a Session and a Cookie in ASP.net?
- Unable to serialize the session state
- C# Clear Session
- how safe is it to use session variables – asp.net / c#
- Can OWIN middleware use the http session?
- Call a stored procedure with parameter in c#
- How to access session variables from any class in ASP.NET?
- Convert webpage to image from ASP.NET
- Convert JSON String to JSON Object c#
- checking user name or user email already exists
- Quartz.net setup in an asp.net website
- Reading FromUri and FromBody at the same time
- Call and consume Web API in winform using C#.net
- asp.net asmx web service returning xml instead of json
- Giving application elevated UAC
- Regex for Money
- DisplayFormat ApplyFormatInEditMode
- Specify Date format in MVC5 (dd/MM/yyyy)
- Amazon SES Email address is not verified