473,320 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Session Checking In Class File

Hello

I created a class which checks session and redirects to login page. My class looks like this. This class inherits Page class to get access to Session object.

1 public class CAuthentication:System.Web.UI.page
2 {
3 public CAuthentication()
4 {
5 if ( Session["login"] == null )
6 Response.Redirect("expired.aspx");
7 }
8 }
9
10

My ASPX.CS looks like



1 public partial class MyPage:CAuthentication
2 {
3 //Pageload goes here
4 }
5

This is not working. I am getting error "session can't be used inside a class". What is wrong here ? Normally codebehind file used to inherit System.Web.UI.Page, Instead of this I inherited this in my CAuthentication class. Where I am going wrong ?

I tried Context.Session also, then it shows Object Reference error. Please help
Aug 4 '07 #1
1 1098
kenobewan
4,871 Expert 4TB
Here is an article that may help:
Working With the Session in ASP.NET
Aug 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
2
by: Jeff User | last post by:
Greetings I am writing code in a C# web service solution. I want to create an instance of an object (that I created) in a Session variable. I need to check to see if the Session variable has...
2
by: tshad | last post by:
I was looking at different ways of doing the same thing and at the moment was looking at the use of "is" and "=", as I have at times found that I will do something like if something = 0 and...
0
by: Andre | last post by:
Hi, I'm using a PCOMM AutSess instantiated class to establish a session with an IBM host (S/390) from within an Excel spreadsheet using: session.SetConnectionByName Not sure how long this...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
7
by: le0 | last post by:
Hello Guys, I have this problem on my page. Im doing my "Logoff" portion, everytime I click "Logoff" then click the Back button in my browser the previous page still appears. Heres my code...
6
by: christopher.j.just | last post by:
I need to set the information being passed through the fields (23 of them) in the form into a session. Where do I start? Thanks, Chris
26
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
4
by: Bjorn Sagbakken | last post by:
In a web-application with login creds (user, pwd), these are checked against a user table on a SQL server. On a positive validation I have saved the userID, name, custno and role-settings in a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.