Murat Aşık Murat Aşık - 8 months ago 63
ASP.NET (C#) Question

C# Checking variables whether defined or not

I just started learning and c#.

Let say I have a session like this:


At a later section, I wanna learn whether that session has been defined. How can i do that ? I tried to do this :

// some code

but of course it didn't work.


Try this code

        if (Session["username"] != null)