Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

response.redirect?

Status
Not open for further replies.

Trebor100

Programmer
Mar 14, 2006
90
GB
Hi all,

fingers crossed this is a quick and easy question.

I'm doing an error control page that attempts to redirect you to your destination every 20 seconds. The error page loads a-okay and redirects when the page is up however if the page is still down i get the diagnose windows connection page. The redirect code is simply:

try
{
Response.Redirect(strUrl);
}
catch
{
//user error message etc
}

What do I need to change for the exceptino to be thrown inside the error page?

Cheers,
Rob
 
because you are swallowing the exception there is no exception after redirecting to the error page.

BTW, this is really bad code. you will need try/catches all over the place with redirects and you lose the exception details as to what went wrong. you can use built-in asp.net hooks to handle error page management without all the try/catch blocks.

Here is just a sampling of the various tools you can use to manage exceptions with the asp.net framework: Global.Application_Error method, Global.Error event. Page.Error event, Page.OnError method, web.config CustomErrors node, Server.GetLastError(), Server.Error

for future reference, since you are working with the asp.net framework, I would recommend forum855 for questions of this nature.

google "asp.net exception handling" for more examples of how to manage exceptions.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top