473,421 Members | 1,595 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,421 software developers and data experts.

Forms auth and session question...

Jon
If a session times out, but the forms auth is still logged in it's possible
for users to go to pages on the site that need those session variables. I
was under the impression that using forms auth would make it so I would not
need to check if session vars were still around.

I'm confused! Perhaps someone can clear this up for me?

--
********************************
Jon
Nov 19 '05 #1
6 1604
Even more than that, should users who's sessions have timed out be able to
even get to the pages? When the session times out and the user makes a page
request, does it take them to the specified "login page"? After that, can
they go to pages that should be restricted? If so, it may have to do with
how you are restricting access to those pages.

Do you use the location tags in the web.config file to restrict directories
or pages?

I beleive the session vars should be gone when a session times out. You
could possible put code in the Session_End event of the Global.asax to be
sure they are cleared, but I wouldn't think this should be necessary,
either.

-Darrin

"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
If a session times out, but the forms auth is still logged in it's
possible for users to go to pages on the site that need those session
variables. I was under the impression that using forms auth would make it
so I would not need to check if session vars were still around.

I'm confused! Perhaps someone can clear this up for me?

--
********************************
Jon

Nov 19 '05 #2
"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
If a session times out, but the forms auth is still logged in it's
possible for users to go to pages on the site that need those session
variables. I was under the impression that using forms auth would make it
so I would not need to check if session vars were still around.

I'm confused! Perhaps someone can clear this up for me?


Forms Authentication is independant of Session. They have nothing to do with
each other.

Consider placing access to Session "variables" into properties which can
handle the case of Session variables disappearing:

Private _table As DataTable

Protected Property Table() As DataTable
Get
If Session("table") Is Nothing Then
' Do whatever you have to in order to get the data
' back into Session state
_table = New DataTable("table")
_table.Columns.Add("column1", GetType(String))
_table.Columns.Add("column2", GetType(String))
Session("table") = _table
Else
_table = DirectCast(Session("table"), DataTable)
End If
End Get
Set(ByVal Value As DataTable)
_table = Value
Session("table") = _table
End Set
End Property

Your code then refers to Table, for instance:

Dim dr As DataRow = Table.NewRow()
dr("column1") = TextBox1.Text.Trim()
dr("column2") = TextBox2.Text.Trim()
Table.Rows.Add(dr)

BTW, Session state can disappear for more than one reason. For instance, if
the application is reset due to changes to web.config or to assemblies in
the bin directory.

Also, as an aside, code like the above also works for data stored in Cache.

John Saunders
Nov 19 '05 #3
Jon
So, if the session can be gone but the user can still have access to a
page...is there a simple way to check on every page for the presence of a
session var without adding code like the following:

if session("var") is nothing then...?

I had created a new base class that inherits web.ui.page and checks for
session...but, then that breaks the designer mode of vs.net. I'm going in
circles here trying to determine the best way to check on every page whether
a session var is set or not. Is it simply to put that code (if
session("var") is nothing...) on every single page?

Thanks for helping me clear this up!
"Darrin J. Olson" <da************@NoSpam.msn.com> wrote in message
news:Op*************@TK2MSFTNGP15.phx.gbl...
Even more than that, should users who's sessions have timed out be able to
even get to the pages? When the session times out and the user makes a
page request, does it take them to the specified "login page"? After that,
can they go to pages that should be restricted? If so, it may have to do
with how you are restricting access to those pages.

Do you use the location tags in the web.config file to restrict
directories or pages?

I beleive the session vars should be gone when a session times out. You
could possible put code in the Session_End event of the Global.asax to be
sure they are cleared, but I wouldn't think this should be necessary,
either.

-Darrin

"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
If a session times out, but the forms auth is still logged in it's
possible for users to go to pages on the site that need those session
variables. I was under the impression that using forms auth would make
it so I would not need to check if session vars were still around.

I'm confused! Perhaps someone can clear this up for me?

--
********************************
Jon


Nov 19 '05 #4
"Jon" <co****@columbusinteractive.com> wrote in message
news:xo*******************@fe2.columbus.rr.com...
So, if the session can be gone but the user can still have access to a
page...is there a simple way to check on every page for the presence of a
session var without adding code like the following:

if session("var") is nothing then...?

I had created a new base class that inherits web.ui.page and checks for
session...but, then that breaks the designer mode of vs.net. I'm going in
circles here trying to determine the best way to check on every page
whether a session var is set or not. Is it simply to put that code (if
session("var") is nothing...) on every single page?
The base page idea works if you don't put any controls in the base page.
However, you can put a property in the base page. Such a property can
contain the code to check for Nothing, so that it doesn't have to be
repeated on each page.

John Saunders
"Darrin J. Olson" <da************@NoSpam.msn.com> wrote in message
news:Op*************@TK2MSFTNGP15.phx.gbl...
Even more than that, should users who's sessions have timed out be able
to even get to the pages? When the session times out and the user makes a
page request, does it take them to the specified "login page"? After
that, can they go to pages that should be restricted? If so, it may have
to do with how you are restricting access to those pages.

Do you use the location tags in the web.config file to restrict
directories or pages?

I beleive the session vars should be gone when a session times out. You
could possible put code in the Session_End event of the Global.asax to be
sure they are cleared, but I wouldn't think this should be necessary,
either.

-Darrin

"Jon" <ru******@msn.com> wrote in message
news:10*************@corp.supernews.com...
If a session times out, but the forms auth is still logged in it's
possible for users to go to pages on the site that need those session
variables. I was under the impression that using forms auth would make
it so I would not need to check if session vars were still around.

I'm confused! Perhaps someone can clear this up for me?

--
********************************
Jon



Nov 19 '05 #5
Jon
"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
The base page idea works if you don't put any controls in the base page.
However, you can put a property in the base page. Such a property can
contain the code to check for Nothing, so that it doesn't have to be
repeated on each page.

John Saunders


I made the following base class and inherit from it and get the deisnger
error. It contains nothing except code to check the session. It's simply a
class file.

*****************
Public Class PageAuth
Inherits System.Web.UI.Page

Public Sub New()
AddHandler MyBase.Load, AddressOf Me.PageAuth_Load
End Sub

Private Sub PageAuth_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
AccessCheck()
End Sub

Private Sub AccessCheck()
Dim oTemp As Object

oTemp = Session("UserEmpNo")

If oTemp Is Nothing Then
Response.Redirect("login.aspx?s=NoSession", True)
End If

If CType(oTemp, String) = "" Then
Response.Redirect("login.aspx?s=NoSession", True)
End If
End Sub
End Class
********************************

I also attempted this by making a new aspx page and put nothing on it except
the following code in the load event, and then inherited from it. Same
error.

******************
Dim oTemp As Object

oTemp = Session("UserEmpNo")

If oTemp Is Nothing Then
Response.Redirect("login.aspx?s=NoSession", True)
End If

If CType(oTemp, String) = "" Then
Response.Redirect("login.aspx?s=NoSession", True)
End If
*******************
Could you possibly show me an actual example of page inheritance working
with the designer. Sample code would be really wonderful at this point. I
appreciate your time!
Nov 19 '05 #6
"Jon" <co****@columbusinteractive.com> wrote in message
news:hX*****************@fe1.columbus.rr.com...
"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
The base page idea works if you don't put any controls in the base page.
However, you can put a property in the base page. Such a property can
contain the code to check for Nothing, so that it doesn't have to be
repeated on each page.

John Saunders


I made the following base class and inherit from it and get the deisnger
error. It contains nothing except code to check the session. It's simply
a class file.


....

Sorry, I just tested with VS2002 and I see that you're right. My experience
was with a base class for UserControls, which works.

The test I did was to create an entirely empty base class (not even a
constructor) which inherits Page. My derived page inherited my base page.
This caused no error from the designer, but the all of the items on the
toolbox "Web Forms" tab were disabled. Strangely, the items on the "HTML"
tab were all enabled and I was able to drag them to the page. Even stranger,
I was able to enter <asp:Label> in the HTML, and see it rendered in the
designer (though I couldn't select it). It works just fine for user
controls, and works for pages in VS2005 Beta 1 (add Inherits="BasePage" to
the <%@ Page %> directive).

Since inheritance doesn't work, a thought is to not inherit from the "base
class", but to have each page contain an instance of it. For instance,
instead of

Public Class WebForm2
Inherits BasePage

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AccessCheck() ' MyBase.AccessCheck()
End Sub
End Class

use

Public Class WebForm2
Inherits System.Web.UI.Page

Private _base As New BasePage()

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
_base.AccessCheck()
End Sub
End Class

John Saunders
Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: 23s | last post by:
I had this problem in the past, after a server reformat it went away, and now after another server reformat it's back again - no clue what's doing it. Here's the flow: Website root is public, no...
1
by: AVance | last post by:
Hi, I've come across this scenario in ASP.NET 1.1 with forms authentication where the forms auth doesn't seem to timeout correctly, nor redirect to the login page. I have done some testing, and...
1
by: Bijoy Naick | last post by:
I have a folder on my site secured with Forms Authentication. After the user is authenticated, I set a session level variable. The session time on the server is set to 20 mins. I am guessing the...
6
by: Patrick Olurotimi Ige | last post by:
I have a Forms Auth and use a button that allows users to SignOut below but when they sign out and PRESS THE BACK BUTTON they can see the previous page WHY? Sub SignOut(objSender As Object,...
4
by: dhnriverside | last post by:
Hi guys Ok, I have a website which has an "Artists Only" section, for which you have to login for. This section is contained within its own directory on the server "/aonly". I want to make...
2
by: pv_kannan | last post by:
I recently found out that my authentication cookies are not expiring even though I have set the persist property to false. As a result, users are able to access the secure websites with indifferent...
7
by: mircu | last post by:
Hi, I noticed weird behaviour with the site that is using forms authentication. I am logged to the site from the same machine from two browsers (opened separately, not ctrl-N) as different users...
0
by: kevin bailey | last post by:
I have a framework working where I have multiple pages each checking the authentication status. Unauthorised users are redirected to a login page - otherwise the requested page is shown. ...
8
by: =?Utf-8?B?TFc=?= | last post by:
Hello! I am just learning about forms authentication so please excuse this basic question. I am using .NET 1.1 and C#. I have created my web.config file and my login.aspx and the associated cs...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.