Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to Redirect a person to a particular page after authentication

Reply
Thread Tools

How to Redirect a person to a particular page after authentication

 
 
savvy
Guest
Posts: n/a
 
      11-17-2005
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="";
}
}

 
Reply With Quote
 
 
 
 
Edwin Knoppert
Guest
Posts: n/a
 
      11-17-2005

I think you should remove:
FormsAuthentication.RedirectFromLoginPage(txtusern ame.Text,false);


"savvy" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) 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="";
> }
> }
>



 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      11-17-2005
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" <(E-Mail Removed)> wrote in message
news:437cb09a$0$2334$(E-Mail Removed). ..
>
> I think you should remove:
> FormsAuthentication.RedirectFromLoginPage(txtusern ame.Text,false);
>
>
> "savvy" <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed) 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="";
>> }
>> }
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect the application to https for particular urls itmohan2002@gmail.com Java 4 11-16-2008 03:53 AM
when I click on "Save as", can I redirect to particular dir, can I control from html code? GS HTML 3 11-14-2006 07:33 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM
Response.redirect for a particular frame in the frameset Anita C ASP .Net 3 02-21-2004 01:12 AM
Redirect Port for a particular IP Andrew Albert Cisco 1 12-06-2003 03:12 AM



Advertisments