C# Possible unintended reference comparison

c#, comparison, reference

Solution

`Session[key]` returns an object, not a string - you should be casting it to string rather than relying on implicit casting or ToString() functionality.

Problem

When i try to check `Session["userId"] != null` why i get this message `Possible unintended reference comparrison; to get value comparrison; cast left hand side to string` Any suggestion....

Original source