473,406 Members | 2,954 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,406 software developers and data experts.

Forms authentication BIG issue

Hello,
I have an application that is using forms authentication and it seems to
be working fine most of the time. Unfortunatelly, it sometimes just redirects
me to the login screen. It seems that the session timed out. But I login
again and do the same action, it redirects me AGAIN to the login page:

1. I login to the app now.
2. I hit some* "server side" link button or button (or any other object that
raises a server side event).
3. The app takes me to the login screen. (Just as if the session had timed
out)
4. I login again to the app.
5. I immediatelly hit on the same "server side" object.
6. I get redirected to the login page again.

* by saying some, I mean that it is a random part of the application. Today
may be on link "A" and tomorrow on button "B"

The whole process can take me as little as few seconds. I can even try to
use a different computer, different user (even different countries!!) and the
problem will be the same.

But if we try later:

7. I login to the application in few hours.
8. I hit on the very same "server side" object.
9. It works perfectly!!!!!
10. I continue to work with the app and in some* other place, I get
redirected to the login screen.

* by saying some, I mean that it is a random part of the application. Today
may be on link "A" and tomorrow on button "B"

I have modified the authentication cookie to be persistant or not, to have
a longer time out period, I have modified the sessionState and the
authentication tags in the web.config and I'm still having the issue.

Any ideas?? Any at all?? I'm willing to try almost everything at this
point!!

Should you have any questions or comments, let me know.

Regards,
Cesar Saucedo

Nov 19 '05 #1
5 1377
Forms authentication does not relate to session at all, except that they
both use cookies to track the user, so changing session will have no effect
on the forms authentication (unless you've somehow built a relationship between
them in your code).

As for your problem, I'd suggest on your login page to check to see if the
user is logged in and if so show their current login on the form. It feels
like to me that your user is logged in and they access a resource where they're
not authorized. Even if you're logged in you'll be sent back to the login
page to provide credentials for the resource you were just trying to access.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hello,
I have an application that is using forms authentication and it
seems to
be working fine most of the time. Unfortunatelly, it sometimes just
redirects
me to the login screen. It seems that the session timed out. But I
login again and do the same action, it redirects me AGAIN to the login
page:

1. I login to the app now.
2. I hit some* "server side" link button or button (or any other
object that
raises a server side event).
3. The app takes me to the login screen. (Just as if the session had
timed
out)
4. I login again to the app.
5. I immediatelly hit on the same "server side" object.
6. I get redirected to the login page again.
* by saying some, I mean that it is a random part of the application.
Today may be on link "A" and tomorrow on button "B"

The whole process can take me as little as few seconds. I can even
try to use a different computer, different user (even different
countries!!) and the problem will be the same.

But if we try later:

7. I login to the application in few hours.
8. I hit on the very same "server side" object.
9. It works perfectly!!!!!
10. I continue to work with the app and in some* other place, I get
redirected to the login screen.
* by saying some, I mean that it is a random part of the application.
Today may be on link "A" and tomorrow on button "B"

I have modified the authentication cookie to be persistant or not,
to have a longer time out period, I have modified the sessionState and
the authentication tags in the web.config and I'm still having the
issue.

Any ideas?? Any at all?? I'm willing to try almost everything at
this point!!

Should you have any questions or comments, let me know.

Regards,
Cesar Saucedo


Nov 19 '05 #2

Can you post the code : web.config and the code you set the FormsAuthentication Ticket ?
"Cesar" <Ce***@discussions.microsoft.com> wrote in message news:B7**********************************@microsof t.com...
Hello,
I have an application that is using forms authentication and it seems to
be working fine most of the time. Unfortunatelly, it sometimes just redirects
me to the login screen. It seems that the session timed out. But I login
again and do the same action, it redirects me AGAIN to the login page:

1. I login to the app now.
2. I hit some* "server side" link button or button (or any other object that
raises a server side event).
3. The app takes me to the login screen. (Just as if the session had timed
out)
4. I login again to the app.
5. I immediatelly hit on the same "server side" object.
6. I get redirected to the login page again.

* by saying some, I mean that it is a random part of the application. Today
may be on link "A" and tomorrow on button "B"

The whole process can take me as little as few seconds. I can even try to
use a different computer, different user (even different countries!!) and the
problem will be the same.

But if we try later:

7. I login to the application in few hours.
8. I hit on the very same "server side" object.
9. It works perfectly!!!!!
10. I continue to work with the app and in some* other place, I get
redirected to the login screen.

* by saying some, I mean that it is a random part of the application. Today
may be on link "A" and tomorrow on button "B"

I have modified the authentication cookie to be persistant or not, to have
a longer time out period, I have modified the sessionState and the
authentication tags in the web.config and I'm still having the issue.

Any ideas?? Any at all?? I'm willing to try almost everything at this
point!!

Should you have any questions or comments, let me know.

Regards,
Cesar Saucedo

Nov 19 '05 #3
See the code below.

"mallik" wrote:

Can you post the code : web.config and the code you set the FormsAuthentication Ticket ?
"Cesar" <Ce***@discussions.microsoft.com> wrote in message news:B7**********************************@microsof t.com...
Hello,
I have an application that is using forms authentication and it seems to
be working fine most of the time. Unfortunatelly, it sometimes just redirects
me to the login screen. It seems that the session timed out. But I login
again and do the same action, it redirects me AGAIN to the login page:

1. I login to the app now.
2. I hit some* "server side" link button or button (or any other object that
raises a server side event).
3. The app takes me to the login screen. (Just as if the session had timed
out)
4. I login again to the app.
5. I immediatelly hit on the same "server side" object.
6. I get redirected to the login page again.

* by saying some, I mean that it is a random part of the application. Today
may be on link "A" and tomorrow on button "B"

The whole process can take me as little as few seconds. I can even try to
use a different computer, different user (even different countries!!) and the
problem will be the same.

But if we try later:

7. I login to the application in few hours.
8. I hit on the very same "server side" object.
9. It works perfectly!!!!!
10. I continue to work with the app and in some* other place, I get
redirected to the login screen.

* by saying some, I mean that it is a random part of the application. Today
may be on link "A" and tomorrow on button "B"

I have modified the authentication cookie to be persistant or not, to have
a longer time out period, I have modified the sessionState and the
authentication tags in the web.config and I'm still having the issue.

Any ideas?? Any at all?? I'm willing to try almost everything at this
point!!

Should you have any questions or comments, let me know.

Regards,
Cesar Saucedo


This is the actual code, I only left out the the appSettings and renamed the
application in the web.config.

Notice that the resource that I'm hitting, is in the "source" folder, not in
the login_head folder

--- web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpRuntime maxRequestLength="4096" />
<compilation defaultLanguage="vb" debug="false" />
<customErrors mode="Off" />

<authentication mode="Forms">
<forms name="MyAppLoginProcess" loginUrl="/MyApp/source/login.aspx"
protection="All" path="/MyApp" timeout="120" />
</authentication>

<trace enabled="false" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true" />
<sessionState mode="InProc" cookieless="false" timeout="120" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8"
culture="en-US" uiCulture="en-US" />
</system.web>
<location allowOverride="true">
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="login_head">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<appSettings>
<!-- My app settings... there are LOTS of them!!! -->
<add key="sAppName" value="MyApp" />
<!-- And many many other config settings -->
</appSettings>

</configuration>
----- In login.aspx.vb

Public Sub fCreateCookie()
Dim tktAuthentication As FormsAuthenticationTicket
Dim strCookie As String
Dim ckkLogin As HttpCookie
Dim intUserType As Int16

' fLogin verify that the user is valid in my database and retrieves the
user type.
' retrieves -1 if the login failed
intUserType = fLogin()

' strUser has the user name
tktAuthentication = New FormsAuthenticationTicket(3, strUser,
DateTime.Now(), _
DateTime.Now.AddMinutes(120), False, intUserType.ToString)
strCookie = FormsAuthentication.Encrypt(tktAuthentication)
ckkLogin = New HttpCookie(FormsAuthentication.FormsCookieName(), strCookie)
Response.Cookies.Add(ckkLogin)
If intUserType < 0 Then
' This function redirects the user to another page that will show
' an error message, destroy the login cookie and redirect to the login
page.
fLogoutRedirect("loginerror")
End If
End Sub

Nov 19 '05 #4
Thank you, I will try that, I have also posted the actual code as response to
mallik in this thread.

Regards,
Cesar

"Brock Allen" wrote:
Forms authentication does not relate to session at all, except that they
both use cookies to track the user, so changing session will have no effect
on the forms authentication (unless you've somehow built a relationship between
them in your code).

As for your problem, I'd suggest on your login page to check to see if the
user is logged in and if so show their current login on the form. It feels
like to me that your user is logged in and they access a resource where they're
not authorized. Even if you're logged in you'll be sent back to the login
page to provide credentials for the resource you were just trying to access.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hello,
I have an application that is using forms authentication and it
seems to
be working fine most of the time. Unfortunatelly, it sometimes just
redirects
me to the login screen. It seems that the session timed out. But I
login again and do the same action, it redirects me AGAIN to the login
page:

1. I login to the app now.
2. I hit some* "server side" link button or button (or any other
object that
raises a server side event).
3. The app takes me to the login screen. (Just as if the session had
timed
out)
4. I login again to the app.
5. I immediatelly hit on the same "server side" object.
6. I get redirected to the login page again.
* by saying some, I mean that it is a random part of the application.
Today may be on link "A" and tomorrow on button "B"

The whole process can take me as little as few seconds. I can even
try to use a different computer, different user (even different
countries!!) and the problem will be the same.

But if we try later:

7. I login to the application in few hours.
8. I hit on the very same "server side" object.
9. It works perfectly!!!!!
10. I continue to work with the app and in some* other place, I get
redirected to the login screen.
* by saying some, I mean that it is a random part of the application.
Today may be on link "A" and tomorrow on button "B"

I have modified the authentication cookie to be persistant or not,
to have a longer time out period, I have modified the sessionState and
the authentication tags in the web.config and I'm still having the
issue.

Any ideas?? Any at all?? I'm willing to try almost everything at
this point!!

Should you have any questions or comments, let me know.

Regards,
Cesar Saucedo


Nov 19 '05 #5

code looks fine to me.
By any chance, you run this application on HTTPS (SSL) ?

"Cesar" <Ce***@discussions.microsoft.com> wrote in message news:92**********************************@microsof t.com...
See the code below.

"mallik" wrote:

Can you post the code : web.config and the code you set the FormsAuthentication Ticket ?


"Cesar" <Ce***@discussions.microsoft.com> wrote in message news:B7**********************************@microsof t.com...
Hello,
I have an application that is using forms authentication and it seems to
be working fine most of the time. Unfortunatelly, it sometimes just redirects
me to the login screen. It seems that the session timed out. But I login
again and do the same action, it redirects me AGAIN to the login page:

1. I login to the app now.
2. I hit some* "server side" link button or button (or any other object that
raises a server side event).
3. The app takes me to the login screen. (Just as if the session had timed
out)
4. I login again to the app.
5. I immediatelly hit on the same "server side" object.
6. I get redirected to the login page again.

* by saying some, I mean that it is a random part of the application. Today
may be on link "A" and tomorrow on button "B"

The whole process can take me as little as few seconds. I can even try to
use a different computer, different user (even different countries!!) and the
problem will be the same.

But if we try later:

7. I login to the application in few hours.
8. I hit on the very same "server side" object.
9. It works perfectly!!!!!
10. I continue to work with the app and in some* other place, I get
redirected to the login screen.

* by saying some, I mean that it is a random part of the application. Today
may be on link "A" and tomorrow on button "B"

I have modified the authentication cookie to be persistant or not, to have
a longer time out period, I have modified the sessionState and the
authentication tags in the web.config and I'm still having the issue.

Any ideas?? Any at all?? I'm willing to try almost everything at this
point!!

Should you have any questions or comments, let me know.

Regards,
Cesar Saucedo


This is the actual code, I only left out the the appSettings and renamed the
application in the web.config.

Notice that the resource that I'm hitting, is in the "source" folder, not in
the login_head folder

--- web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpRuntime maxRequestLength="4096" />
<compilation defaultLanguage="vb" debug="false" />
<customErrors mode="Off" />

<authentication mode="Forms">
<forms name="MyAppLoginProcess" loginUrl="/MyApp/source/login.aspx"
protection="All" path="/MyApp" timeout="120" />
</authentication>

<trace enabled="false" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true" />
<sessionState mode="InProc" cookieless="false" timeout="120" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8"
culture="en-US" uiCulture="en-US" />
</system.web>
<location allowOverride="true">
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="login_head">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<appSettings>
<!-- My app settings... there are LOTS of them!!! -->
<add key="sAppName" value="MyApp" />
<!-- And many many other config settings -->
</appSettings>

</configuration>


----- In login.aspx.vb

Public Sub fCreateCookie()
Dim tktAuthentication As FormsAuthenticationTicket
Dim strCookie As String
Dim ckkLogin As HttpCookie
Dim intUserType As Int16

' fLogin verify that the user is valid in my database and retrieves the
user type.
' retrieves -1 if the login failed
intUserType = fLogin()

' strUser has the user name
tktAuthentication = New FormsAuthenticationTicket(3, strUser,
DateTime.Now(), _
DateTime.Now.AddMinutes(120), False, intUserType.ToString)
strCookie = FormsAuthentication.Encrypt(tktAuthentication)
ckkLogin = New HttpCookie(FormsAuthentication.FormsCookieName(), strCookie)
Response.Cookies.Add(ckkLogin)
If intUserType < 0 Then
' This function redirects the user to another page that will show
' an error message, destroy the login cookie and redirect to the login
page.
fLogoutRedirect("loginerror")
End If
End Sub

Nov 19 '05 #6

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

Similar topics

1
by: MJ | last post by:
I'm building an application that has a file structure similar to the following: /myapp/user_login.aspx /myapp/user_page_1.aspx /myapp/user_page_2.aspx /myapp/user_page_3.aspx...
4
by: Greg Burns | last post by:
I have built a web app that uses forms authentication. There isn't a "remember me" feature (i.e. the authentication cookie is not permanent). When you close the browser, and open a new one, you...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
7
by: Justin | last post by:
I am trying to password protect a subdirectory using forms authentication. I am using the "Location" tag to specify the directory to be protected. The login.aspx page is in the root directory of...
2
by: Wiktor Zychla [C# MVP] | last post by:
Hi, I struggle for over an hour with the integrated Cassini web server. the problem I am facing is as follows: when I turn forms authentication on in the web.config file, the website seems to...
6
by: eric.olstad | last post by:
I'm pullin my hair out here. I've created a login page that uses Forms Authentication. Initially, it loads the types of authentication methods from a database and asks the user to select the auth...
4
by: =?Utf-8?B?RmFyaWJh?= | last post by:
It know that we can use the following method http://msdn2.microsoft.com/en-us/library/eb0zx8fc.aspx to form authenticate across multiple applications. I have created an asp.net application...
3
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, we've got a strange problem here: We've created an ASP.NET 2.0 web application using Membership.ValidateUser() to manually authenticate users with our website. The problem is: If the...
4
by: =?Utf-8?B?R3V1czEyMw==?= | last post by:
Hi, I created a web site on a remote server. To logon the user must enter a user id and password. The site is uses Forms Authentication. The web config file looks as follows: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...

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.