473,585 Members | 2,657 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automatic Redirection from login page to previous page

pentahari
60 New Member
Redirect to login page if session("UserNa me") is expired when the page useraccount.asp x load event


My useraccount.asp x 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.as px; useraccount.asp x 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 3828
Curtis Rutland
3,256 Recognized Expert Specialist
Did you make sure to set Session("UserNa me") equal to some value after a successful login? If you forgot to set it, its value would still be Nothing.
Jul 2 '08 #2
pentahari
60 New Member
Did you make sure to set Session("UserNa me") 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 New Member
Redirect to login page if session("UserNa me") is expired when the page useraccount.asp x load event


My useraccount.asp x 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.as px; useraccount.asp x 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 Recognized Expert Specialist
Even easier is to use membership class of .net 2.0. HTH.
Jul 2 '08 #5
pentahari
60 New Member
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 Recognized Expert Specialist
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 misunderstandin g your problem. Sorry about that. Glad you solved it.
Jul 2 '08 #7
pentahari
60 New Member
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 New Member
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
6263
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 login is correct a session variable containing the username is set and the user is redirected to the (restricted access) main menu page. The...
2
3160
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 page 2. capture and parse the content from the status_main.htm page On the SMC's login.htm page there is a form with the following elements:...
0
1778
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 must first go to the login.asp page before accessing any other .asp page. I have set up a redirection method so that if a user pastes a URL to an...
0
1679
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 done. There should be a DHCP server setup which gives the arriving clients IP, default router address etc. Where should the homepage redirection be...
6
1935
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 if the user has logged in. If not, it redirects them to the login page for authentication. After authenticating, I want to redirect them back to...
3
2755
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 but they don't seem to take any effect <authentication mode="Forms">
10
8142
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 authenticated and login the system automatically base on the username and password already in the session. Is that possible to do ? and how to do...
9
2002
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 application calls FormsAuthentication.RedirectToLoginPage() then the URL becomes malformed. I then recieve the following error, "The return URL...
33
2638
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 redirection to http://new.com which does not update the client browser's address bar Q2 ... or is this one of the main benefits of the IIS URL rewriter ??
0
7908
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...
0
7836
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
8199
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
8336
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
8212
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...
0
6606
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...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
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

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.