Problem with response.redirect [Resolved]

Posted by Sheesh under Regular Expressions on 6/8/2011 | Points: 10 | Views : 17591 | Status : [Member] | Replies : 4
Hi,
I am using response.redirect to redirect the page from one to another page & previously it was working fine. My calling method is to call login page & after checking user id & password, it then redirect to company login page & after checking company user id password it then redirect to default.aspx page. But now the problem is, it is not redirecting to company login page rather it sticks there only displaying no error . If I am using server.transfer in place of response.redirect , it then redirects to company login page, but it can't redirect to default.aspx page from company login, it again sticks there. Now the code is written as

Login.aspx page

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
try
{
Response.Redirect("~/CompanyLogin.aspx");
Response.End();
}
catch (Exception)
{
throw;
}

}

CompanyLogin.aspx
protected void Btn1_Click1(object sender, EventArgs e)
{
try
{
Response.Redirect("~/Default.aspx");
Response.End();
}
catch (Exception)
{
throw;
}
}

Urgently provide any solution.

thanks
regards

Thanks
Regards



Responses

Posted by: Sheesh on: 6/10/2011 [Member] Starter | Points: 25

Up
0
Down

Resolved
Hi,
After using Login control in asp.net, now the page is redirected to other page by just setting the changes to Destination Url.

Thanks
Regards

Sheesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: SheoNarayan on: 6/8/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
What is the use of writing Response.Redirect in the try block? It will throw error in all cases (try to debug and it will throw error).

Simply remove the try catch block and things should work.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Sheesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheesh on: 6/8/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
That's also the main thing, if not using try catch block then too the same thing happens, i.e not redirecting to other page & also while debugging no error were raised. If all the codes are in the try catch block & while debugging no error were raised, & after authenticating user credentials it simply sticks to that page only, means it is not redirecting to company login page.
Morever there is no change in execution if false is used in response.redirect i.e. it simply sticks to that page only after authenticating user credentials.
If true is used then it simply clears the user id & password from the form & sticks there only.
Using ThreadAbortException in catch block no error message is raised.
Without using try catch block again same thing happen i.e. sticks to that page only.
I cannot understand why this happens as previously it was working fine with the same code.

Any other suggestion..??
Thanks
Regards

Thanks
Regards

Sheesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gsolvers on: 6/11/2011 [Member] Starter | Points: 25

Up
0
Down
try this as well


Response.Redirect("~/Default.aspx",true);

Best Regards,

VG
www.TeacherJi.com

Sheesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response