Groups | Blog | Home
all groups > asp.net > march 2004 >

asp.net : application crash in try catch


Nileshw
3/1/2004 11:31:07 PM
I am using try catch in my application. If I use response.redirect in try catch and suppose any error occur in response.redirect line , that error is not catched but crash my application

For exampl

private sub subRedirectTo(
tr
response.redirect("wrongfilename"

catch ex as exceptio

throw ex

end tr

end su

In above example suppose the URL name is wrong or file name is wrong then that exception is not handled in
catch part but application get crash on response.redirect line

How to solve this proble

Thanks and regard
Eric Lawrence [MSFT]
3/2/2004 12:18:39 AM
Can you elaborate on what you mean when you say the "application get crash"
on the response redirect line? What exactly is happening?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

[quoted text, click to view]
catch and suppose any error occur in response.redirect line , that error is
not catched but crash my application.
[quoted text, click to view]

Sorin Dolha [MCSD .NET]
3/2/2004 10:23:41 AM
Nileshw,

Redirecting to a web page that doesn't exist is not an exception, from =
the code point of view. The code managed to do the right job: it sent a =
request to the client browser to navigate to the page URL specified as =
the parameter for the Redirect() method. Therefore, no exception is =
thrown and no exception is to be caught on the server side code.

The problem will occur only later, when the client browser finds out =
that the requested URL is not found or that there was a problem when =
loading the new page from its web server (which may be another web =
server, from another part of the world). The client then displays a =
message describing the problem - but the server is now away from the =
situation.

If you redirect to a page existing in the same web application and want =
to generate an exception from the server side code, try to look for the =
required page (for example, using =
File.Exists(Server.MapPath("yourpage")) and if it doesn't exist, throw =
an exception yourself, from code (throw new Exception("yourpage was not =
found")), before redirecting.

I hope it helped,

--=20
Sorin Dolha [MCAD, MCSD .NET]

[quoted text, click to view]
I am using try catch in my application. If I use response.redirect in =
try catch and suppose any error occur in response.redirect line , that =
error is not catched but crash my application.

For example

private sub subRedirectTo()
try
response.redirect("wrongfilename")
=20
catch ex as exception

throw ex=20
=20
end try

end sub

In above example suppose the URL name is wrong or file =
name is wrong then that exception is not handled in=20
catch part but application get crash on =
response.redirect line.

How to solve this problem

Thanks and regards
Anatoly
3/2/2004 5:24:22 PM
For your information:
If you do redirect inside try block exception thrown and catch block =
executes.

[quoted text, click to view]
Nileshw,

Redirecting to a web page that doesn't exist is not an exception, from =
the code point of view. The code managed to do the right job: it sent a =
request to the client browser to navigate to the page URL specified as =
the parameter for the Redirect() method. Therefore, no exception is =
thrown and no exception is to be caught on the server side code.

The problem will occur only later, when the client browser finds out =
that the requested URL is not found or that there was a problem when =
loading the new page from its web server (which may be another web =
server, from another part of the world). The client then displays a =
message describing the problem - but the server is now away from the =
situation.

If you redirect to a page existing in the same web application and =
want to generate an exception from the server side code, try to look for =
the required page (for example, using =
File.Exists(Server.MapPath("yourpage")) and if it doesn't exist, throw =
an exception yourself, from code (throw new Exception("yourpage was not =
found")), before redirecting.

I hope it helped,

--=20
Sorin Dolha [MCAD, MCSD .NET]

[quoted text, click to view]
I am using try catch in my application. If I use response.redirect =
in try catch and suppose any error occur in response.redirect line , =
that error is not catched but crash my application.

For example

private sub subRedirectTo()
try
response.redirect("wrongfilename")
=20
catch ex as exception

throw ex=20
=20
end try

end sub

In above example suppose the URL name is wrong or =
file name is wrong then that exception is not handled in=20
catch part but application get crash on =
response.redirect line.

How to solve this problem

Thanks and regards
Sorin Dolha [MCSD .NET]
3/2/2004 5:36:59 PM
Nobody said they don't. But if the redirect is to an incorrect URL no =
exception is thrown (no exception is generated by the Redirect =
statement, even if the URL is incorrect).

--=20
Sorin Dolha [MCAD, MCSD .NET]
[quoted text, click to view]
For your information:
If you do redirect inside try block exception thrown and catch block =
executes.

[quoted text, click to view]
Nileshw,

Redirecting to a web page that doesn't exist is not an exception, =
from the code point of view. The code managed to do the right job: it =
sent a request to the client browser to navigate to the page URL =
specified as the parameter for the Redirect() method. Therefore, no =
exception is thrown and no exception is to be caught on the server side =
code.

The problem will occur only later, when the client browser finds out =
that the requested URL is not found or that there was a problem when =
loading the new page from its web server (which may be another web =
server, from another part of the world). The client then displays a =
message describing the problem - but the server is now away from the =
situation.

If you redirect to a page existing in the same web application and =
want to generate an exception from the server side code, try to look for =
the required page (for example, using =
File.Exists(Server.MapPath("yourpage")) and if it doesn't exist, throw =
an exception yourself, from code (throw new Exception("yourpage was not =
found")), before redirecting.

I hope it helped,

--=20
Sorin Dolha [MCAD, MCSD .NET]

[quoted text, click to view]
I am using try catch in my application. If I use response.redirect =
in try catch and suppose any error occur in response.redirect line , =
that error is not catched but crash my application.

For example

private sub subRedirectTo()
try
response.redirect("wrongfilename")
=20
catch ex as exception

throw ex=20
=20
end try

end sub

In above example suppose the URL name is wrong or =
file name is wrong then that exception is not handled in=20
catch part but application get crash on =
response.redirect line.

How to solve this problem

Thanks and regards
AddThis Social Bookmark Button