473,511 Members | 15,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem With Froms Authentication. HELP

Hi:

I have got a problem with FromsAuthentication for many days.
I use "Forms" Authentication in my ASP.NET Web Froms, and I find
that I can't singout....

Some Code Here:
//In my Logon.aspx, I got the username and password
//then I check these in my database

//logon.aspx
protected void btnLogin_Click(object sender, EventArgs e)
{
long sid = Student.TestPassword(username, password);
if (sid == -1) return false;

Student student = new Student(sid);
SchoolPrincipal principal = new SchoolPrincipal(student);
String userdata = principal.Identity.ToString();
FormsAuthenticationTicket authTicket = new
FormsAuthenticationTicket(1, username, DateTime.Now,
DateTime.Now.AddMinutes(20), false, userdata);
string encyptionTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encyptionTicket);
authCookie.Expires = DateTime.Now.AddMinutes(5);
Response.Cookies.Add(authCookie);

return true;
}

//SchoolPrincipal is a class interface IPrincipal
//I create it on my logon.aspx
//and rebuild it in my gobal.asax
//gobal.asax
protected void Application_AuthenticateRequest(object sender,
System.EventArgs e)
{
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (null == authCookie) return;

FormsAuthenticationTicket authTicket = null;
try
{
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
}
catch
{
return;
}

SchoolPrincipal principal = new
SchoolPrincipal(authTicket.UserData);

if (principal.Identity == null) return;
else Context.User = principal;

}
//that is part of my code
//Login is OK, but it Will never logout until I close the navigater
//My Logout Code Here

private void Logout ()
{
FormsAuthentication.SignOut();
}

So, I have trap for many days
Any help would be appriciate
Thanks
//Chen
Nov 19 '05 #1
3 2143
When you say it will never logout are u expecting the below to fire??:-
private void Logout ()
{
FormsAuthentication.SignOut();
} Where is the page you are redirecting it to for it to logout(it needs to go
somewhere)
Rote


"JMUApache" <ma********@163.com> wrote in message
news:rn********************************@4ax.com... Hi:

I have got a problem with FromsAuthentication for many days.
I use "Forms" Authentication in my ASP.NET Web Froms, and I find
that I can't singout....

Some Code Here:
//In my Logon.aspx, I got the username and password
//then I check these in my database

//logon.aspx
protected void btnLogin_Click(object sender, EventArgs e)
{
long sid = Student.TestPassword(username, password);
if (sid == -1) return false;

Student student = new Student(sid);
SchoolPrincipal principal = new SchoolPrincipal(student);
String userdata = principal.Identity.ToString();
FormsAuthenticationTicket authTicket = new
FormsAuthenticationTicket(1, username, DateTime.Now,
DateTime.Now.AddMinutes(20), false, userdata);
string encyptionTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encyptionTicket);
authCookie.Expires = DateTime.Now.AddMinutes(5);
Response.Cookies.Add(authCookie);

return true;
}

//SchoolPrincipal is a class interface IPrincipal
//I create it on my logon.aspx
//and rebuild it in my gobal.asax
//gobal.asax
protected void Application_AuthenticateRequest(object sender,
System.EventArgs e)
{
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (null == authCookie) return;

FormsAuthenticationTicket authTicket = null;
try
{
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
}
catch
{
return;
}

SchoolPrincipal principal = new
SchoolPrincipal(authTicket.UserData);

if (principal.Identity == null) return;
else Context.User = principal;

}
//that is part of my code
//Login is OK, but it Will never logout until I close the navigater
//My Logout Code Here

private void Logout ()
{
FormsAuthentication.SignOut();
}

So, I have trap for many days
Any help would be appriciate
Thanks
//Chen

Nov 19 '05 #2
Hi

It redirect to default page logon.aspx
but it doesn't signout

I have try use code like this
Session.Abandon ();
Response.Cookie.Clear ();
//somebody has suggest me do this
but it does nothing

So what is wrong with my web application?

Any suggest would be appriciate.
Thanks

//chen

On Fri, 30 Sep 2005 22:01:59 +1000, "Patrick.O.Ige"
<pa********@optusnet.com.au> wrote:
When you say it will never logout are u expecting the below to fire??:-
private void Logout ()
{
FormsAuthentication.SignOut();
}

Where is the page you are redirecting it to for it to logout(it needs to go
somewhere)
Rote


"JMUApache" <ma********@163.com> wrote in message
news:rn********************************@4ax.com.. .
Hi:

I have got a problem with FromsAuthentication for many days.
I use "Forms" Authentication in my ASP.NET Web Froms, and I find
that I can't singout....

Some Code Here:
//In my Logon.aspx, I got the username and password
//then I check these in my database

//logon.aspx
protected void btnLogin_Click(object sender, EventArgs e)
{
long sid = Student.TestPassword(username, password);
if (sid == -1) return false;

Student student = new Student(sid);
SchoolPrincipal principal = new SchoolPrincipal(student);
String userdata = principal.Identity.ToString();
FormsAuthenticationTicket authTicket = new
FormsAuthenticationTicket(1, username, DateTime.Now,
DateTime.Now.AddMinutes(20), false, userdata);
string encyptionTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encyptionTicket);
authCookie.Expires = DateTime.Now.AddMinutes(5);
Response.Cookies.Add(authCookie);

return true;
}

//SchoolPrincipal is a class interface IPrincipal
//I create it on my logon.aspx
//and rebuild it in my gobal.asax
//gobal.asax
protected void Application_AuthenticateRequest(object sender,
System.EventArgs e)
{
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (null == authCookie) return;

FormsAuthenticationTicket authTicket = null;
try
{
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
}
catch
{
return;
}

SchoolPrincipal principal = new
SchoolPrincipal(authTicket.UserData);

if (principal.Identity == null) return;
else Context.User = principal;

}
//that is part of my code
//Login is OK, but it Will never logout until I close the navigater
//My Logout Code Here

private void Logout ()
{
FormsAuthentication.SignOut();
}

So, I have trap for many days
Any help would be appriciate
Thanks
//Chen


Nov 19 '05 #3
Chen do you want it to do what the code below says?:-
Session.Abandon ();
Response.Cookie.Clear (); Beacuse i don't understand if you say it doesn't do anything?
Or may be what you want to achieve is after logging out and
try going back you want the user to log in again.
Which means you want to clear the session ,cookies etc?
Patrick

"JMUApache" <ma********@163.com> wrote in message
news:qn********************************@4ax.com... Hi

It redirect to default page logon.aspx
but it doesn't signout

I have try use code like this
Session.Abandon ();
Response.Cookie.Clear ();
//somebody has suggest me do this
but it does nothing

So what is wrong with my web application?

Any suggest would be appriciate.
Thanks

//chen

On Fri, 30 Sep 2005 22:01:59 +1000, "Patrick.O.Ige"
<pa********@optusnet.com.au> wrote:
When you say it will never logout are u expecting the below to fire??:-
private void Logout ()
{
FormsAuthentication.SignOut();
}

Where is the page you are redirecting it to for it to logout(it needs to gosomewhere)
Rote


"JMUApache" <ma********@163.com> wrote in message
news:rn********************************@4ax.com.. .
Hi:

I have got a problem with FromsAuthentication for many days.
I use "Forms" Authentication in my ASP.NET Web Froms, and I find
that I can't singout....

Some Code Here:
//In my Logon.aspx, I got the username and password
//then I check these in my database

//logon.aspx
protected void btnLogin_Click(object sender, EventArgs e)
{
long sid = Student.TestPassword(username, password);
if (sid == -1) return false;

Student student = new Student(sid);
SchoolPrincipal principal = new SchoolPrincipal(student);
String userdata = principal.Identity.ToString();
FormsAuthenticationTicket authTicket = new
FormsAuthenticationTicket(1, username, DateTime.Now,
DateTime.Now.AddMinutes(20), false, userdata);
string encyptionTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encyptionTicket);
authCookie.Expires = DateTime.Now.AddMinutes(5);
Response.Cookies.Add(authCookie);

return true;
}

//SchoolPrincipal is a class interface IPrincipal
//I create it on my logon.aspx
//and rebuild it in my gobal.asax
//gobal.asax
protected void Application_AuthenticateRequest(object sender,
System.EventArgs e)
{
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (null == authCookie) return;

FormsAuthenticationTicket authTicket = null;
try
{
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
}
catch
{
return;
}

SchoolPrincipal principal = new
SchoolPrincipal(authTicket.UserData);

if (principal.Identity == null) return;
else Context.User = principal;

}
//that is part of my code
//Login is OK, but it Will never logout until I close the navigater
//My Logout Code Here

private void Logout ()
{
FormsAuthentication.SignOut();
}

So, I have trap for many days
Any help would be appriciate
Thanks
//Chen

Nov 19 '05 #4

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

Similar topics

5
1414
by: Mainard | last post by:
Hi, all First off I know alittle about javascript, but i have never worked with controlling froms with it be for i wonder can some help me? for example:I have this <textarea name"write1">Write...
0
3777
by: awan | last post by:
hi, I wanna migrate 6i forms to 10g forms....I compiled 6i forms in 10g form builder ,froms compiled successfully and add some settings in fromsweb file....which is as follows: ...
4
2174
by: Grind Boy | last post by:
Hi, I'm writing this off the top of my head as I don't have the exact information to hand. We are attempting to set up a secure internet site using ASP.NET on IIS5. We are having some...
0
1112
by: Raed Sawalha | last post by:
The thing is that I want to put authentication application to the webserver root (C:\Inetpub\wwwroot\empLogin.aspx & http:\\localhost\emplogin.aspx) The problem is that another webApplication...
6
1629
by: TJS | last post by:
i'm having problems where the user is not correctly redirected to login page if starting in a folder below the webroot. in these cases, it always tries to go to /foldername/login.aspx this is...
6
1692
by: Jéjé | last post by:
Hi, I have a custom aspx page which access RS (Reporting Services) using the webservice interface. I'm using the delegation (defautcredentialcache) to send the user authentication to RS. RS...
2
1801
by: ruca | last post by:
Hi, My Web App have Windows Authentication, that don't function in Opera Browser. How come? How can I get resolution for this problem?!?!?!??!
1
417
by: Steven M. | last post by:
Greetings... I need desperate help with my problem. I guess the solution is related in some way with the cookies getting lost in the authentication process working with some web servers. ...
1
1188
by: Lloyd Dupont | last post by:
I'm trying to setup a very simple form authentication in my WebApp (a few user in an XML file). I'm also trying to use the Role in my application. I don't want to use a database. I'm trying...
0
7237
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,...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
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
5659
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
4734
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...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.