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

Automatic Redirection from login page to previous page

pentahari
Redirect to login page if session("UserName") is expired when the page useraccount.aspx load event


My useraccount.aspx code :

Expand|Select|Wrap|Line Numbers
  1. If Session("UserName") Is Nothing Then
  2.     Response.Redirect("../login/login.aspx")
  3. End If
The above code works correctly. but my question is the user enter the correct username and password in the login.aspx page . it will automatically redirect to previous page (useraccount.aspx; useraccount.aspx is the sample name of the page but i have used the session redirect coding to many pages in my project).
Jul 2 '08 #1
8 3811
Curtis Rutland
3,256 Expert 2GB
Did you make sure to set Session("UserName") equal to some value after a successful login? If you forgot to set it, its value would still be Nothing.
Jul 2 '08 #2
Did you make sure to set Session("UserName") equal to some value after a successful login? If you forgot to set it, its value would still be Nothing.
Sure. I have assign the value to session variable.
Jul 2 '08 #3
alag20
84
Redirect to login page if session("UserName") is expired when the page useraccount.aspx load event


My useraccount.aspx code :

Expand|Select|Wrap|Line Numbers
  1. If Session("UserName") Is Nothing Then
  2.     Response.Redirect("../login/login.aspx")
  3. End If
The above code works correctly. but my question is the user enter the correct username and password in the login.aspx page . it will automatically redirect to previous page (useraccount.aspx; useraccount.aspx is the sample name of the page but i have used the session redirect coding to many pages in my project).
You can try to lock the login by directory. For this you will need to modify your web.config to specify which folder is login restricted and what url is the login page. Once you have done this, normally the redirect is handled by IIS which I would recommend.


Another option for you is to add the url from which you are directing to the login url as a variable in the url / in a session. On successful login, redirect to that variable url if availlable otherwise the default page. Though I would recommend using the first method!
Jul 2 '08 #4
kenobewan
4,871 Expert 4TB
Even easier is to use membership class of .net 2.0. HTH.
Jul 2 '08 #5
Thanks for yours post.

I have solved the problems by store the current page URL to session variable when checking the session expiry, and it call back from after successful login.
Jul 2 '08 #6
Curtis Rutland
3,256 Expert 2GB
Thanks for yours post.

I have solved the problems by store the current page URL to session variable when checking the session expiry, and it call back from after successful login.
I see that I was misunderstanding your problem. Sorry about that. Glad you solved it.
Jul 2 '08 #7
I have found the easy way to this problem.

pass the current URL as query string to login page when the check session expiry operation.
Jul 3 '08 #8
alag20
84
I have found the easy way to this problem.

pass the current URL as query string to login page when the check session expiry operation.
Glad to hear that it worked out for you. Though for future you might want to check my other option as it is url encodes the url for you automatically!
Jul 3 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nick Whitelegg | last post by:
Hello, I'm having an odd problem with combining an authentication session variable with header() redirection. Basically I have an authentication script which checks a username/password. If the...
2
by: TJ Talluto | last post by:
Hi, I'm using the curl functions in php to scrape the wan ip address from my home router (the router is an SMC product). This is a two step process: 1. post the password value to the login.htm...
0
by: Mike | last post by:
I can not figure out what is going on here. I hope somebody can please help!!! I've got an intranet ASP3 application running on a Win2k server. This application requires a login, so the user...
0
by: itsharkopath | last post by:
Hi, Imagine a user in a hotspot, when he comes to the hotspot and tries to load a webpage (on the internet), he would automatically redirected to login page. I believe the following is to be...
6
by: Donald Williamson | last post by:
Hi Hope someone can help me with authentication and how the redirects work. I' ve already tried searching previous posts but didn't really find anything. for I have a page that checks to see...
3
by: David Kleyman | last post by:
Hello I would like to find out if there is a way to SignOut() the user and redirect the browser back to login page after time out period expired I've added these settings to my web.config file...
10
by: Victor | last post by:
hi guys. In my project, now I am using a asp.net login control and a customized membership provider to do the form authentication. Now I want some function that user can skip the login form and be...
9
by: Nick | last post by:
Hi there, I'm passing an HTML encoded string to an URL in the query parameter. This query string works perfect in the website if you are already logged on, if you are not logged on the...
33
by: rvj | last post by:
if you redirect on an IIS , must the client url address bar always be updated with the new address. what options are? Q1 if a user requests http://old.com , is there a method of ASP...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.