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

What if I dont want to redirect after a user logs in?

I'm using Forms authentication with my user data in a SQL db. I have pages
in the main appliaction folder accessible to anonymous users and I've set
security to deny annonymous users access to pages in several sub folders
(e.g. admin). I've set up a login page where users trying to access any
/admin/ page are diverted to and on successful login they are redirected
back to the page they requested.

All is well. Everything works.

I want it to work a different way.

I want to display a user control on every page to enable a visitor to login
at any time (or log out if he's logged in) and to show options appropriate
to logged in users. I have it mostly working BUT when my user is on page
/somepage.aspx and logs in I want him to see page /somepage.aspx again
(revised with appropriate options for a logged in user) and *not*
default.aspx or any other page.

FormsAuthentication seems to demand that I send my user away to another
page, and uses Default.aspx if there isn't one specified in the URL.

How can I get my user authenticated and keep him on the same page?

I guess I'm looking for a
FormsAuthentication.AuthenticateButDontRedirectAny where() method.

Anyone done this? Anyone tell me where I should be looking?

Brian Lowe
---------@

Nov 18 '05 #1
4 1604
FormsAuthentication.SetAuthCookie

"Brian Lowe" <no@reply.address> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm using Forms authentication with my user data in a SQL db. I have pages
in the main appliaction folder accessible to anonymous users and I've set
security to deny annonymous users access to pages in several sub folders
(e.g. admin). I've set up a login page where users trying to access any
/admin/ page are diverted to and on successful login they are redirected
back to the page they requested.

All is well. Everything works.

I want it to work a different way.

I want to display a user control on every page to enable a visitor to login at any time (or log out if he's logged in) and to show options appropriate
to logged in users. I have it mostly working BUT when my user is on page
/somepage.aspx and logs in I want him to see page /somepage.aspx again
(revised with appropriate options for a logged in user) and *not*
default.aspx or any other page.

FormsAuthentication seems to demand that I send my user away to another
page, and uses Default.aspx if there isn't one specified in the URL.

How can I get my user authenticated and keep him on the same page?

I guess I'm looking for a
FormsAuthentication.AuthenticateButDontRedirectAny where() method.

Anyone done this? Anyone tell me where I should be looking?

Brian Lowe
---------@


Nov 18 '05 #2
You are reinventing the wheel, to an extent, but I can understand the issue.

What I have done is create the majority of the page (anything that can have
multiple states, like logged in, not logged in) in controls (server or user,
your choice). I then set up a user object when the user logs in. A user can
surf the entire site, but the user object is null until he logs in. To test
basic state, I simply pull the user object and test if it is null. If so,
don't show logged in elements; if not null, show them. There are a couple of
ways to handle this, from Session["userObject"] to creating a singleton.
NOTE: You can also use the extremely thin Session["LoggedIn"].

The next version of .NET has more facilities that do this "automagically".

This also allows me to have role based security, as the logged in user may
belong to different roles. I have created a UserInRole() method of my user
object that tests the user against a role, or roles. You may not need to go
this far.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Brian Lowe" <no@reply.address> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm using Forms authentication with my user data in a SQL db. I have pages
in the main appliaction folder accessible to anonymous users and I've set
security to deny annonymous users access to pages in several sub folders
(e.g. admin). I've set up a login page where users trying to access any
/admin/ page are diverted to and on successful login they are redirected
back to the page they requested.

All is well. Everything works.

I want it to work a different way.

I want to display a user control on every page to enable a visitor to login at any time (or log out if he's logged in) and to show options appropriate
to logged in users. I have it mostly working BUT when my user is on page
/somepage.aspx and logs in I want him to see page /somepage.aspx again
(revised with appropriate options for a logged in user) and *not*
default.aspx or any other page.

FormsAuthentication seems to demand that I send my user away to another
page, and uses Default.aspx if there isn't one specified in the URL.

How can I get my user authenticated and keep him on the same page?

I guess I'm looking for a
FormsAuthentication.AuthenticateButDontRedirectAny where() method.

Anyone done this? Anyone tell me where I should be looking?

Brian Lowe
---------@


Nov 18 '05 #3
It really is that obvious!

Thanks for pointing this out. I don't know how I missed it in my search
through the docs, but now I see it it does exactly what I want. I must
havebeen looking for some wierd thing!

Thanks!

Brian Lowe
---------@
"Rick Spiewak" <ri*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
FormsAuthentication.SetAuthCookie

Nov 18 '05 #4
Thanks but you seem to be answering a question I didn't ask.

Rick Spiewak answered it very succinctly.

What you describe is broadly what I had done in classic ASP for previous
applications, including a roll-your-own roles based model. Now that it's
all built in to ASP.Net I'm keen to take advantage of what's already there.

Brian Lowe
---------@

"Cowboy" <No************@comcast.netNoSpamM> wrote in message
news:eV**************@TK2MSFTNGP12.phx.gbl...
You are reinventing the wheel, to an extent, but I can understand the issue.

Nov 18 '05 #5

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

Similar topics

7
by: Alex Hunsley | last post by:
I'm making a web site that does login authentication. It all works fine, but I have a question about 'correctness'... Certain php scripts on the site should only run in the user has logged on....
5
by: Hal Vaughan | last post by:
I have a Java program, composed of a number of classes, that I've been running as a command line program. It logs everything it does and, as it logs each event, it also prints that line of info to...
0
by: Ed Henn | last post by:
I'm having a problem with .NET Forms Authentication in a particular application. It's not redirecting properly when my session is timed out, seemingly only when I POST the page (i.e. click a form...
2
by: Dr. Paul Caesar - CoullByte (UK) Limited | last post by:
Hi, I have created a Logout ASP.NET application using Forms Authentication. When a user logs out they get a confirmation page confirming logout and a button to click to return to the homepage....
5
by: kevin goff | last post by:
I am seeing that our CPU spikes for several minutes at 100% for the asp.net process. This happens several times a day and seems to last for 10 min or so and use a lot of memory. I'm trying to...
8
by: fredda054 | last post by:
Hi everybody ! I have a little repeater/hyperlink issue I'm not sure how to solve. I use a repeater to list subjects available at a specific school. The datasource of this repeater is a...
17
by: Luc Mercier | last post by:
Hi Folks, I'm new here, and I need some advice for what tool to use. I'm using XML for benchmarking purposes. I'm writing some scientific programs which I want to analyze. My program generates...
1
by: =?Utf-8?B?TWFya1I=?= | last post by:
I have somewhat older ASP application that is running on a client's web server and is in the process of being written as .net. However, in the meantime, due to the authentication interface that the...
6
by: pek | last post by:
I have read a lot of tutorials on how to create a login mechanism (a lot of which I found really useful). None of them however explain how do you check if the user is or is not in fact logged in. ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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
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...

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.