473,799 Members | 3,005 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 FromsAuthentica tion 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.TestPas sword(username, password);
if (sid == -1) return false;

Student student = new Student(sid);
SchoolPrincipal principal = new SchoolPrincipal (student);
String userdata = principal.Ident ity.ToString();
FormsAuthentica tionTicket authTicket = new
FormsAuthentica tionTicket(1, username, DateTime.Now,
DateTime.Now.Ad dMinutes(20), false, userdata);
string encyptionTicket = FormsAuthentica tion.Encrypt(au thTicket);
HttpCookie authCookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, encyptionTicket );
authCookie.Expi res = DateTime.Now.Ad dMinutes(5);
Response.Cookie s.Add(authCooki e);

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_Aut henticateReques t(object sender,
System.EventArg s e)
{
string cookieName = FormsAuthentica tion.FormsCooki eName;
HttpCookie authCookie = Context.Request .Cookies[cookieName];
if (null == authCookie) return;

FormsAuthentica tionTicket authTicket = null;
try
{
authTicket = FormsAuthentica tion.Decrypt(au thCookie.Value) ;
}
catch
{
return;
}

SchoolPrincipal principal = new
SchoolPrincipal (authTicket.Use rData);

if (principal.Iden tity == 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 ()
{
FormsAuthentica tion.SignOut();
}

So, I have trap for many days
Any help would be appriciate
Thanks
//Chen
Nov 19 '05 #1
3 2162
When you say it will never logout are u expecting the below to fire??:-
private void Logout ()
{
FormsAuthentica tion.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.c om... Hi:

I have got a problem with FromsAuthentica tion 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.TestPas sword(username, password);
if (sid == -1) return false;

Student student = new Student(sid);
SchoolPrincipal principal = new SchoolPrincipal (student);
String userdata = principal.Ident ity.ToString();
FormsAuthentica tionTicket authTicket = new
FormsAuthentica tionTicket(1, username, DateTime.Now,
DateTime.Now.Ad dMinutes(20), false, userdata);
string encyptionTicket = FormsAuthentica tion.Encrypt(au thTicket);
HttpCookie authCookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, encyptionTicket );
authCookie.Expi res = DateTime.Now.Ad dMinutes(5);
Response.Cookie s.Add(authCooki e);

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_Aut henticateReques t(object sender,
System.EventArg s e)
{
string cookieName = FormsAuthentica tion.FormsCooki eName;
HttpCookie authCookie = Context.Request .Cookies[cookieName];
if (null == authCookie) return;

FormsAuthentica tionTicket authTicket = null;
try
{
authTicket = FormsAuthentica tion.Decrypt(au thCookie.Value) ;
}
catch
{
return;
}

SchoolPrincipal principal = new
SchoolPrincipal (authTicket.Use rData);

if (principal.Iden tity == 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 ()
{
FormsAuthentica tion.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********@opt usnet.com.au> wrote:
When you say it will never logout are u expecting the below to fire??:-
private void Logout ()
{
FormsAuthentica tion.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 FromsAuthentica tion 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.TestPas sword(username, password);
if (sid == -1) return false;

Student student = new Student(sid);
SchoolPrincipal principal = new SchoolPrincipal (student);
String userdata = principal.Ident ity.ToString();
FormsAuthentica tionTicket authTicket = new
FormsAuthentica tionTicket(1, username, DateTime.Now,
DateTime.Now.Ad dMinutes(20), false, userdata);
string encyptionTicket = FormsAuthentica tion.Encrypt(au thTicket);
HttpCookie authCookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, encyptionTicket );
authCookie.Expi res = DateTime.Now.Ad dMinutes(5);
Response.Cookie s.Add(authCooki e);

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_Aut henticateReques t(object sender,
System.EventArg s e)
{
string cookieName = FormsAuthentica tion.FormsCooki eName;
HttpCookie authCookie = Context.Request .Cookies[cookieName];
if (null == authCookie) return;

FormsAuthentica tionTicket authTicket = null;
try
{
authTicket = FormsAuthentica tion.Decrypt(au thCookie.Value) ;
}
catch
{
return;
}

SchoolPrincipal principal = new
SchoolPrincipal (authTicket.Use rData);

if (principal.Iden tity == 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 ()
{
FormsAuthentica tion.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.c om... 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********@opt usnet.com.au> wrote:
When you say it will never logout are u expecting the below to fire??:-
private void Logout ()
{
FormsAuthentica tion.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 FromsAuthentica tion 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.TestPas sword(username, password);
if (sid == -1) return false;

Student student = new Student(sid);
SchoolPrincipal principal = new SchoolPrincipal (student);
String userdata = principal.Ident ity.ToString();
FormsAuthentica tionTicket authTicket = new
FormsAuthentica tionTicket(1, username, DateTime.Now,
DateTime.Now.Ad dMinutes(20), false, userdata);
string encyptionTicket = FormsAuthentica tion.Encrypt(au thTicket);
HttpCookie authCookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, encyptionTicket );
authCookie.Expi res = DateTime.Now.Ad dMinutes(5);
Response.Cookie s.Add(authCooki e);

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_Aut henticateReques t(object sender,
System.EventArg s e)
{
string cookieName = FormsAuthentica tion.FormsCooki eName;
HttpCookie authCookie = Context.Request .Cookies[cookieName];
if (null == authCookie) return;

FormsAuthentica tionTicket authTicket = null;
try
{
authTicket = FormsAuthentica tion.Decrypt(au thCookie.Value) ;
}
catch
{
return;
}

SchoolPrincipal principal = new
SchoolPrincipal (authTicket.Use rData);

if (principal.Iden tity == 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 ()
{
FormsAuthentica tion.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
1452
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 Your Message:</textarea> on a form called myform2, and i have another form and textarea on another page. how am i to send the text from one from to the other form?
0
3789
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: #http://http://awan.rdcci.org.sa:8889/forms/frmservlet?config=train1 #D:\DevSuiteHome_1\forms\server *** copy formsweb.cfg file in this directory #D:\DevSuiteHome_1\forms\java *** copy GIF files in this directory ( icons for toolbar ) ...
4
2209
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 authentication problems early on in the project. The plan is to have 1 ASP.NET (IIS) forms application serving user requests and another ASP.NET (IIS) webservice interfacing to the database.
0
1123
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 myPDF <(It uses aspx authentication to safeguard pdf files - really cool - just had to relate pdf extension in IIS to aspNet)> ( C:\Inetpub\wwwroot\myPDF\getList.aspx & http:\\localhost\myPDF\getList.aspx ) needs that authentication. So i set up...
6
1639
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 the web.config code: .... <authentication mode="Forms"> <forms name="testAuthCookie" loginUrl="/_security/login.aspx" /> </authentication> ....
6
1704
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 and my web application are on the same server. this works fine in 2 cases:
2
1812
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. Appreciate any help you could provide. I've created an application that does the authentication process
1
1202
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 to call Rolls.AddUserToRole(username, role) but I get an exception: ProviderException what could I do?
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10491
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10268
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10031
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.