473,406 Members | 2,713 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,406 software developers and data experts.

How to Redirect a person to a particular page after authentication

I am using the code below to check whether a member is valid or not ,
and if he is then allowing him to certain parts of the site. My problem
is when a person logs on by entering his user ID and pwd he'll always
be directed to the index.aspx page.if he clicks APPLY JOB button it
should first ask for login details and then i want him to get directed
to the respective page (applyjob.aspx) not the index.aspx. I cant do
Response.Redirect then it will directly all my pages to the
applyjob.aspx. I hope i made some sense till now. Can anyone help me in
this pleas
Thanks in Advance
private void btnlogin_Click(object sender, System.EventArgs e)
{
bool blnAuthentication =
Authenticate(txtusername.Text,txtpassword.Text);
if(blnAuthentication)
{
FormsAuthentication.RedirectFromLoginPage(txtusern ame.Text,false);
Session["isMemberLoggedIn"]= true;
Response.Redirect("index.aspx");
}
else
{
Session["isMemberLoggedIn"]= false;
lblErr.Text = "Your Login was invalid. Please try again.";
txtusername.Text="";
}
}

Nov 20 '05 #1
2 1406

I think you should remove:
FormsAuthentication.RedirectFromLoginPage(txtusern ame.Text,false);
"savvy" <jo******@gmail.com> schreef in bericht
news:11**********************@f14g2000cwb.googlegr oups.com...
I am using the code below to check whether a member is valid or not ,
and if he is then allowing him to certain parts of the site. My problem
is when a person logs on by entering his user ID and pwd he'll always
be directed to the index.aspx page.if he clicks APPLY JOB button it
should first ask for login details and then i want him to get directed
to the respective page (applyjob.aspx) not the index.aspx. I cant do
Response.Redirect then it will directly all my pages to the
applyjob.aspx. I hope i made some sense till now. Can anyone help me in
this pleas
Thanks in Advance
private void btnlogin_Click(object sender, System.EventArgs e)
{
bool blnAuthentication =
Authenticate(txtusername.Text,txtpassword.Text);
if(blnAuthentication)
{
FormsAuthentication.RedirectFromLoginPage(txtusern ame.Text,false);
Session["isMemberLoggedIn"]= true;
Response.Redirect("index.aspx");
}
else
{
Session["isMemberLoggedIn"]= false;
lblErr.Text = "Your Login was invalid. Please try again.";
txtusername.Text="";
}
}

Nov 20 '05 #2
Partially.

redirectFromLogin page does 2 things
(a) sets the authentication cookie
(b) redirects

You want to remove the call to RedirectFromLoginPage

but you must replace it with FormsAuthentication.SetAuthCookie and then you
can redirect as your example does.

Karl

P.S. - why use a session to track if the user is logged in if you are using
forms authentication?
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Edwin Knoppert" <ne**@hellobasic.com> wrote in message
news:43**********************@text.nova.planet.nl. ..

I think you should remove:
FormsAuthentication.RedirectFromLoginPage(txtusern ame.Text,false);
"savvy" <jo******@gmail.com> schreef in bericht
news:11**********************@f14g2000cwb.googlegr oups.com...
I am using the code below to check whether a member is valid or not ,
and if he is then allowing him to certain parts of the site. My problem
is when a person logs on by entering his user ID and pwd he'll always
be directed to the index.aspx page.if he clicks APPLY JOB button it
should first ask for login details and then i want him to get directed
to the respective page (applyjob.aspx) not the index.aspx. I cant do
Response.Redirect then it will directly all my pages to the
applyjob.aspx. I hope i made some sense till now. Can anyone help me in
this pleas
Thanks in Advance
private void btnlogin_Click(object sender, System.EventArgs e)
{
bool blnAuthentication =
Authenticate(txtusername.Text,txtpassword.Text);
if(blnAuthentication)
{
FormsAuthentication.RedirectFromLoginPage(txtusern ame.Text,false);
Session["isMemberLoggedIn"]= true;
Response.Redirect("index.aspx");
}
else
{
Session["isMemberLoggedIn"]= false;
lblErr.Text = "Your Login was invalid. Please try again.";
txtusername.Text="";
}
}


Nov 20 '05 #3

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

Similar topics

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...
4
by: Dave | last post by:
Hi, Is there anyway to mimic forms authentication's loginUrl and RedirectFromLoginPage functionality using Windows authentication? We are developing intranet sites using basic authentication...
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...
3
by: Peter Row | last post by:
Hi, I better get the background stuff out the way first, so here goes: - Porting a VB6 webclass app to VB.NET using HttpHandlers and FormsAuthentication - When someone visits my site...
1
by: Ather Ali Shaikh | last post by:
Hello I am using Forms Authentication. but the page is not redirect to desired login page after session is expired. When I debug the application. Session_end is called. In the Session_End method...
1
by: Grey | last post by:
I have set the following parameters in web.config to prevent user direct access the web page without user login. <authentication mode="Forms"> <forms loginUrl="Initial/index.aspx"...
1
by: Sospeter | last post by:
Hi Ken, I have done that but still experiencing same problem. Tried the following i.e. turning smartnavigation = false and using server.transfer as below but nothing works. Please help. ...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
1
by: rouellette | last post by:
Is it possible to redirect to another page in your application from the start page BEFORE the user has been authenticated if you're using FORMS authentication? I can't seem to get it to work. ...
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...
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
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...
0
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,...
0
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...

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.