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

Membership - Log Out Programatically

Hi All,

I have a situation where I am using a login control to log a user in to
my web app.
Under the LoginButton_Click handler of the login control, I retrive some
custom user information from the database.
Based on this information, the situation may arise where I want to log
the user out automatically even if a valid username/password has been
entered in the login control.

I have tried using:
Session.Abandon()
FormsAuthentication.SignOut()
and this doesnt seem to work, does anyone have any ideas how I can
acomplish a logout via code?

Regards
Mick
Jul 17 '07 #1
4 5094
Mick Walker wrote:
Hi All,

I have a situation where I am using a login control to log a user in to
my web app.
Under the LoginButton_Click handler of the login control, I retrive some
custom user information from the database.
Based on this information, the situation may arise where I want to log
the user out automatically even if a valid username/password has been
entered in the login control.

I have tried using:
Session.Abandon()
FormsAuthentication.SignOut()
and this doesnt seem to work, does anyone have any ideas how I can
acomplish a logout via code?

Regards
Mick
Oh I forgot to mention I am using Forms Authentication, here is the
relevent info from my web.config
<membership defaultProvider="CustomizedProvider">
<providers>
<add name="CustomizedProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SDConn" minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add connectionStringName="SDConn" name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
<authentication mode="Forms"/>
Jul 17 '07 #2
On Jul 17, 3:44 pm, Mick Walker <Mick.Wal...@privacy.netwrote:
Mick Walker wrote:
Hi All,
I have a situation where I am using a login control to log a user in to
my web app.
Under the LoginButton_Click handler of the login control, I retrive some
custom user information from the database.
Based on this information, the situation may arise where I want to log
the user out automatically even if a valid username/password has been
entered in the login control.
I have tried using:
Session.Abandon()
FormsAuthentication.SignOut()
and this doesnt seem to work, does anyone have any ideas how I can
acomplish a logout via code?
Regards
Mick

Oh I forgot to mention I am using Forms Authentication, here is the
relevent info from my web.config
<membership defaultProvider="CustomizedProvider">
<providers>
<add name="CustomizedProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SDConn" minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add connectionStringName="SDConn" name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
<authentication mode="Forms"/>- Hide quoted text -

- Show quoted text -
Maybe change the role of a user could help you here?

Jul 18 '07 #3
Alexey Smirnov wrote:
On Jul 17, 3:44 pm, Mick Walker <Mick.Wal...@privacy.netwrote:
>Mick Walker wrote:
>>Hi All,
I have a situation where I am using a login control to log a user in to
my web app.
Under the LoginButton_Click handler of the login control, I retrive some
custom user information from the database.
Based on this information, the situation may arise where I want to log
the user out automatically even if a valid username/password has been
entered in the login control.
I have tried using:
Session.Abandon()
FormsAuthentication.SignOut()
and this doesnt seem to work, does anyone have any ideas how I can
acomplish a logout via code?
Regards
Mick
Oh I forgot to mention I am using Forms Authentication, here is the
relevent info from my web.config
<membership defaultProvider="CustomizedProvider">
<providers>
<add name="CustomizedProvider"
type="System.Web.Security.SqlMembershipProvider "
connectionStringName="SDConn" minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add connectionStringName="SDConn" name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
<authentication mode="Forms"/>- Hide quoted text -

- Show quoted text -

Maybe change the role of a user could help you here?
I can't see how this would help me to be honest. At present I only have
two roles. User and Moderator.

Could you elaborate please?
Jul 19 '07 #4
On Jul 19, 3:05 am, Mick Walker <Mick.Wal...@privacy.netwrote:
Alexey Smirnov wrote:
On Jul 17, 3:44 pm, Mick Walker <Mick.Wal...@privacy.netwrote:
Mick Walker wrote:
Hi All,
I have a situation where I am using a login control to log a user in to
my web app.
Under the LoginButton_Click handler of the login control, I retrive some
custom user information from the database.
Based on this information, the situation may arise where I want to log
the user out automatically even if a valid username/password has been
entered in the login control.
I have tried using:
Session.Abandon()
FormsAuthentication.SignOut()
and this doesnt seem to work, does anyone have any ideas how I can
acomplish a logout via code?
Regards
Mick
Oh I forgot to mention I am using Forms Authentication, here is the
relevent info from my web.config
<membership defaultProvider="CustomizedProvider">
<providers>
<add name="CustomizedProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SDConn" minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add connectionStringName="SDConn" name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
<authentication mode="Forms"/>- Hide quoted text -
- Show quoted text -
Maybe change the role of a user could help you here?

I can't see how this would help me to be honest. At present I only have
two roles. User and Moderator.

Could you elaborate please?
you could create a 3rd role like 'lockedout' and deny this role the
rights to view content

Jul 19 '07 #5

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

Similar topics

1
by: Karen Hill | last post by:
I would like to be able to programatically check for group membership in an access database. For example, I would like to be able to check is someone is in the admin group before the program does...
9
by: Paul Keegstra | last post by:
Hi, I am currently working on an asp.net 2.0 web site that is a replacement of a classic asp web site. The current web site uses a Commerce Server 2002 database for storing user information. ...
3
by: ibiza | last post by:
Hi all, I am currently developing in asp.net 2.0 and I was at first impressed with the numerous login and user controls they provided to ease the task of managing users. But I am starting to...
2
by: Balaji | last post by:
Hi All, Can I use more than one membership provider for a given website? I understand only one of them could be default one. If yes, then how to programmatically access the other membership...
3
by: ryan.mclean | last post by:
Hello everyone, I am wondering, can the membership provider be changed at runtime? Perhaps the connectionStringName? I would like to use a different database based on the server the site is...
4
by: =?Utf-8?B?Q2hyaXMgQ2Fw?= | last post by:
I have been having some trouble with implementing a custom Membership Provider. We have a custom data store and business logic that pulls user information. I need some level of functionality...
3
by: Glenn | last post by:
My current classic-ASP site has users, projects, roles and the 2.0 membership looks like a perfect fit, but I'm having trouble finding examples of how to have users that belong to different...
1
by: =?Utf-8?B?ZVByaW50?= | last post by:
Asp.Net v2.0 I have created a web application and I am using it from a single website and database. The web application has different ‘portals’ – each independent and I am using the...
2
by: NitinSawant | last post by:
Hello, How to Programatically Update Membership Role i.e. Rename a role using C#? In "Roles" class there are methods to add,read, delete roles but there is no method to Update the role......
0
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,...
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: 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$) { } ...
0
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...
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
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...
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...

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.