Determine if ASP.NET Sessions are enabled
NickName:Keith Adler Ask DateTime:2009-08-27T02:52:38

Determine if ASP.NET Sessions are enabled

What is the best way to do a boolean test in C# to determine if ASP.NET sessions are enabled? I don't want to use a try-catch block and Sessions != null throws an Exception.

Regards.

Copyright Notice:Content Author:「Keith Adler」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/1336770/determine-if-asp-net-sessions-are-enabled

Answers
John Rasch 2009-08-26T19:21:35

You will not get an exception if you use HttpContext.Current:\n\nif(HttpContext.Current.Session != null)\n{\n // Session!\n}\n",


More about “Determine if ASP.NET Sessions are enabled” related questions

Determine if ASP.NET Sessions are enabled

What is the best way to do a boolean test in C# to determine if ASP.NET sessions are enabled? I don't want to use a try-catch block and Sessions != null throws an Exception. Regards.

Show Detail

Determine if sessions are enabled client-side

How can I determine, if client browser supports sessions? I'm working on a anti-flood script - I want to limit the operations on the script to 5 seconds for each operation, and I want to store the...

Show Detail

Determine if sessions are enabled on an Azure Service Bus Queue

Is there a way in C# to programmatically determine if sessions are enabled on an Azure ServiceBus Queue? I am using the Azure.Messaging.ServiceBus. I can see the older version has a way of determ...

Show Detail

Determine which objects in ASP.NET are used in session

I have inherited a very large ASP.NET app that needs to be modified to use a State Server instead of in-proc sessions. I need to track down all classes used in session throughout the app and then

Show Detail

How can I determine the number of users on an ASP.NET site (IIS)? And their info?

Is there a way to determine the number of users that have active sessions in an ASP.NET application? I have an admin/tools page in a particular application, and I would like to display info regard...

Show Detail

Determine user sessions in Mysql

how can I determine the session times of these fictitious users? As an example, for user 1 I assume that between 08:24:08 and 15:08:20 he wasn't there, so I don't add that time interval, I add the ...

Show Detail

How to determine if ASAM is enabled?

I want to be able to determine if it's safe to attempt to enable ASAM mode. To determine this, it would be helpful if I could tell if SAM is enable, or ASAM is already enabled, or, in general, which

Show Detail

Leverage ASP.NET Sessions in WCF

I have the following configuration at the service side <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5"/>

Show Detail

How to check if sessions are on

What is the easiest way in PHP to determine whether or not sessions are enabled in the php.ini file for the server. I am looking to make a pre-installation check for my PHP app and just need someth...

Show Detail

Sessions and performance in asp.net MVC

Is it true that asp.net MVC doesn't use SESSIONS [Sessions varibale] and hence there it's performance is better than asp.net webform. if this is not the case then why the speed of asp.net MVC is fa...

Show Detail