Errorhandling with response.redirect

R

Roel

Hello

When I have an exception within a try - catch block, I sent the user to my
error page with the following code:
Response.Redirect(@"error.aspx?errmsg=" + ex.Message + "&errsource=" +
ex.Source + "&errstack=" + ex.StackTrace);

The problem is that when there is an \n - sign in the error message or
stacktrace, I get the error "Redirect URI cannot contain newline characters"

Is there anybody who knows how I can transform the "ex.Message" into a
@string or is there another way to solve this problem

Regards
Roel
 
M

Marina

There are probably newlines in pretty much all of the variables you are
getting. You can try calling Server.UrlEncode.

However, keep in mind that there are also length limits on how many
characters can be passed in the query string.
 
J

John Wood

It seems like that querystring could be huge, especially with the stacktrace
in there.

Perhaps it might be an idea to investigate passing information to your error
page via session settings, or perhaps even storing the information in a
database on the server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top