Murat Aşık Murat Aşık - 1 year ago 98
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.

Answer Source

Try this code

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download