473,545 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

FormsAuthentica tion 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
FormsAuthentica tion.Authentica teButDontRedire ctAnywhere() method.

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

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

Nov 18 '05 #1
4 1618
FormsAuthentica tion.SetAuthCoo kie

"Brian Lowe" <no@reply.addre ss> wrote in message
news:%2******** ********@tk2msf tngp13.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.

FormsAuthentica tion 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
FormsAuthentica tion.Authentica teButDontRedire ctAnywhere() 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.addre ss> wrote in message
news:%2******** ********@tk2msf tngp13.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.

FormsAuthentica tion 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
FormsAuthentica tion.Authentica teButDontRedire ctAnywhere() 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*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
FormsAuthentica tion.SetAuthCoo kie

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.netNoS pamM> wrote in message
news:eV******** ******@TK2MSFTN GP12.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
4768
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. So, the 'private' scripts in question all includes the following php script: <? // has user authenticated? if (! $logged_in) {
5
4264
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 the console. I would like to create a wrapper class to open a window, call my application, and redirect all the output to a TextField in the...
0
1181
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 submit button). If I try to GET a page after timeout (i.e. just picking a page to visit from a menu), I am redirected to the login screen properly....
2
2848
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. We have the page designed so that if the user is not authenticated then they get redirected using Response Redirect method to the homapage.
5
1180
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 find out what page it is that is causing these problems. How can i find out what pages are executing at the time of the spike? Thanks, kevin goff...
8
3160
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 dataset filled with info from a SQL Server database. All the subjects are displayed as hyperlinks, and when a user clicks a subject, it opens up a new...
17
2287
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 large XML logs giving semi-structured information on the flow of the program. The XML tree looks like the method calls tree, but at a much higher...
1
1201
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 client has in place we were forced to create one ASP.net web page that interfaces to this authentication program, and then redirects back to the...
6
1670
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. What is your implementation? What do you believe is a good practice and what is not? Do you provide both sessions and cookies for temporal and...
0
7425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7682
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. ...
0
7935
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...
0
6009
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...
1
5351
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...
0
5069
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...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
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 we have to send another system
0
734
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.