Hi, For some reason my session are expireing when the web browser
closes and User.Identity.IsAuthenticated is truning true,
I have a webcrontrol from login:
Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn
Dim UserTicket As FormsAuthenticationTicket = New
FormsAuthenticationTicket(1, Login1.UserName, DateAndTime.Now,
DateAndTime.Now.AddSeconds(1), False, "WebUser",
FormsAuthentication.FormsCookiePath)
FormsAuthentication.Encrypt(UserTicket)
end sub
and in my secure page i have tha fallowing:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not User.Identity.IsAuthenticated Then
FormsAuthentication.RedirectToLoginPage()
Exit Sub
End If
did i do anything wrong ?
p.s: my authentication type is :form !
thank you 2 4852
hi zulander,
can you post your web.config? i usually secure pages or folders via
web.config with a <locationssetting instead of by code.
i know you said you have Forms Auth in your web.config, but it looks like
that isn't set up correctly, or else the Forms ticket is still valid in
Page_Load.
also, why are you granting the ticket for 1 second?
it may help to find out what User.Identity.Name is in your Page_Load, it
could be the IIS guest account or the Forms user.
tim
"Zulander" <zu******@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi, For some reason my session are expireing when the web browser
closes and User.Identity.IsAuthenticated is truning true,
I have a webcrontrol from login:
Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn
Dim UserTicket As FormsAuthenticationTicket = New
FormsAuthenticationTicket(1, Login1.UserName, DateAndTime.Now,
DateAndTime.Now.AddSeconds(1), False, "WebUser",
FormsAuthentication.FormsCookiePath)
FormsAuthentication.Encrypt(UserTicket)
end sub
and in my secure page i have tha fallowing:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not User.Identity.IsAuthenticated Then
FormsAuthentication.RedirectToLoginPage()
Exit Sub
End If
did i do anything wrong ?
p.s: my authentication type is :form !
thank you
Tim_Mac, This is my web.config
<authentication mode="Forms">
<forms loginUrl="login.aspx"/>
</authentication>
<location path="login.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
The part with the one second is that i was testing if it was the cause
of not expiring,
it was actualy: Dim UserTicket As FormsAuthenticationTicket =
New FormsAuthenticationTicket(1, Login1.UserName, DateAndTime.Now,
DateAndTime.Now, False, "WebUser", FormsAuthentication.FormsCookiePath)
The, user is the authenticated user that was loged therfore it is not
the guest account !
thank you
Tim_Mac wrote:
hi zulander,
can you post your web.config? i usually secure pages or folders via
web.config with a <locationssetting instead of by code.
i know you said you have Forms Auth in your web.config, but it looks like
that isn't set up correctly, or else the Forms ticket is still valid in
Page_Load.
also, why are you granting the ticket for 1 second?
it may help to find out what User.Identity.Name is in your Page_Load, it
could be the IIS guest account or the Forms user.
tim
"Zulander" <zu******@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi, For some reason my session are expireing when the web browser
closes and User.Identity.IsAuthenticated is truning true,
I have a webcrontrol from login:
Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn
Dim UserTicket As FormsAuthenticationTicket = New
FormsAuthenticationTicket(1, Login1.UserName, DateAndTime.Now,
DateAndTime.Now.AddSeconds(1), False, "WebUser",
FormsAuthentication.FormsCookiePath)
FormsAuthentication.Encrypt(UserTicket)
end sub
and in my secure page i have tha fallowing:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not User.Identity.IsAuthenticated Then
FormsAuthentication.RedirectToLoginPage()
Exit Sub
End If
did i do anything wrong ?
p.s: my authentication type is :form !
thank you
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris |
last post by:
Hi,
I am learning C# and basically using a .asp net app I wrote in VB and
converting to C#.
in VB code :
If Context.User.Identity.IsAuthenticated Then
obj =...
|
by: Jesper Stocholm |
last post by:
I have implemented role-based security within my ASP.Net application.
However, it seems the role is not passed to the authentication ticket I
create.
I want to use it to display/hide some...
|
by: |
last post by:
Hi!
1st:
when I debug this:
FormsAuthentication.SetAuthCookie(email.Text, RememberCheckbox.Checked)
and set a breakpoint a line after
|
by: Razak |
last post by:
Hi,
I have a class which basically do Impersonation in my web application. From
MS KB sample:-
++++++++++++++++++++code starts
Dim impersonationContext As...
|
by: Tom Nowak |
last post by:
I am writing a webapp in which a user is required to enter a login id and
password on a login form. I have forms authenticaion coded in my web.config.
Once the user is logged in, I want to use the...
|
by: Siobhan |
last post by:
Hi
What is the recommended way to store a user's database credentials across
the pages of a web application so that each time the database is accessed the
system doesn't have to ask them for their...
|
by: zhuang |
last post by:
Hi,
I have problem with below code:
WindowsPrincipal principal ;
principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
WindowsIdentity identity = (WindowsIdentity)...
|
by: shapper |
last post by:
Hello,
I need to check if a user is authenticated. I tried everything I could
think and find:
If Membership.ValidateUser("shapper", "27lamps11") Then...
|
by: =?Utf-8?B?Q2hhcmxlc0E=?= |
last post by:
hi folks,
I've got XP pro service pack 2 VS 2005 TSE with ASP.net 2.0 and C#
I'm doing an example from Stephen Walther's so far excellent book and he
has a whole load of stuff to add the...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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...
|
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: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |