473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

errorhandling with response.redirect

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


Nov 18 '05 #1
4 1282
Roel,

The quick answer is to URL-encode the string using the UrlEncode method of
the Server object. However, this is not a good general solution since the
limitations on query string lengths are likely to cause eventual problems.
A better solution is to not pass the error message via the query string at
all. You might want to try either a server-side redirection or storing the
exception information in a session variable for retrieval on the error page.

HTH,
Nicole
"Roel" <vd*****@pandora.be> wrote in message
news:OH**************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #2
use Server.Transfer("error.aspx") and in the error.aspx page access the
error as Server.GetLastError()

Av.
"Roel" <vd*****@pandora.be> wrote in message
news:OH**************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #3
You could also stuff the error in the Session, then call Server.Transfer and read the error out on the error.aspx page.

"avnrao" wrote:
use Server.Transfer("error.aspx") and in the error.aspx page access the
error as Server.GetLastError()

Av.
"Roel" <vd*****@pandora.be> wrote in message
news:OH**************@TK2MSFTNGP11.phx.gbl...
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



Nov 18 '05 #4
thx to all, I solved my problem usign all your answers together
<David Coe>; "MCAD" <Da**********@discussions.microsoft.com> wrote in
message news:F7**********************************@microsof t.com...
You could also stuff the error in the Session, then call Server.Transfer and read the error out on the error.aspx page.
"avnrao" wrote:
use Server.Transfer("error.aspx") and in the error.aspx page access the
error as Server.GetLastError()

Av.
"Roel" <vd*****@pandora.be> wrote in message
news:OH**************@TK2MSFTNGP11.phx.gbl...
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



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect...
4
by: JC | last post by:
Hi, I have a simple question regarding the Response.Redirect method. Does the server stop processing the ASP code as soon as it encounters the Redirect command? Or does it ever continue to...
4
by: TomT | last post by:
Hi.. I'm redirecting users to another page using: response.redirect("newpage.asp") this works... But I need to add a variable to the page specified.. IE: newpage.asp?id=JobID
4
by: Roel | last post by:
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=" +...
6
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx...
3
by: Sehboo | last post by:
On my ASP page, when I click a button, I want to do three things: 1. Check for some values. 2. Open a new window and pass some values as query string. 3. Redirect to some other page Here...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
4
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the...
9
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case)....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.