|
-
Mar 26th, 2007, 10:14 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Redirect URI cannot contain newline characters
Hello everybody,
On my button click event, I am getting Redirect URI cannot contain newline characters exception. I do not have any Response.Redirect in my event handler routine. Here's my code.
Code:
private void btnAddCustomer_Click(object sender, System.EventArgs e)
{
try
{
if(ValidateClientSide())
{
DataTable dtPlan = new DataTable();
PCSN.SurveyApplicationCustomerArea.BusinessLogicLayer.Plan plan = new PCSN.SurveyApplicationCustomerArea.BusinessLogicLayer.Plan();
dtPlan = plan.GetPlanByName("Evaluation Plan");
long planID = 0;
string membershipDate = DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Year.ToString();
string expiryDate = "";
bool isActive = false;
string amount = "0";
long paymentTypeID = 0;
long paymentModeID = 0;
if(dtPlan.Rows.Count > 0)
{
planID = Convert.ToInt32(dtPlan.Rows[0]["ID"]);
long numDays = Convert.ToInt32(dtPlan.Rows[0]["NumDays"]);
DateTime tempExpiryDate = new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day).AddDays(numDays);
expiryDate = tempExpiryDate.ToShortDateString();
amount = dtPlan.Rows[0]["Amount"].ToString().Trim();
}
PCSN.SurveyApplicationCustomerArea.BusinessLogicLayer.PaymentType paymentType = new PCSN.SurveyApplicationCustomerArea.BusinessLogicLayer.PaymentType();
DataTable dtPaymentType = new DataTable();
dtPaymentType = paymentType.GetPaymentTypeByName("New Member");
if(dtPaymentType.Rows.Count > 0)
paymentTypeID = Convert.ToInt32(dtPaymentType.Rows[0]["ID"]);
PCSN.SurveyApplicationCustomerArea.BusinessLogicLayer.PaymentMode paymentMode = new PCSN.SurveyApplicationCustomerArea.BusinessLogicLayer.PaymentMode();
DataTable dtPaymentMode = new DataTable();
dtPaymentMode = paymentMode.GetPaymentModeByName("No Payment");
if(dtPaymentMode.Rows.Count > 0)
paymentModeID = Convert.ToInt32(dtPaymentMode.Rows[0]["ID"]);
string customerNumber = InsertCustomer(txtPassword.Text.Trim(),membershipDate,expiryDate,txtFirstName.Text.Trim(),txtLastName.Text.Trim(),txtEmail.Text.Trim(),txtCompanyName.Text.Trim(),txtPhoneNumber.Text.Trim(),txtCellNumber.Text.Trim(),txtAddress.Text.Trim(),txtCity.Text.Trim(),txtState.Text.Trim(),txtZipCode.Text.Trim(),Convert.ToInt32(cboCountries.SelectedValue),planID,isActive,amount,paymentTypeID,paymentModeID);
string result = "You account has been created and a confirmation email has been sent to your email address with details to activate the account.";
DataTable dtEmailMessage = new DataTable();
PCSN.SurveyApplicationCustomerArea.BusinessLogicLayer.EmailMessage emailMessage = new PCSN.SurveyApplicationCustomerArea.BusinessLogicLayer.EmailMessage();
dtEmailMessage = emailMessage.GetEmailMessageForNewCustomer();
string fromAddress = "";
string toAddress = "";
string subject = "";
string message = "";
string url;
if(dtEmailMessage.Rows.Count > 0)
{
fromAddress = dtEmailMessage.Rows[0]["FromAddress"].ToString().Trim();
subject = dtEmailMessage.Rows[0]["Subject"].ToString().Trim();
message = dtEmailMessage.Rows[0]["Message"].ToString().Trim();
}
DataTable dtCustomer = new DataTable();
dtCustomer = GetCustomerByCustomerNumber(customerNumber);
toAddress = dtCustomer.Rows[0]["Email"].ToString().Trim();
url = FormatUrl(dtCustomer.Rows[0]["ID"].ToString().Trim(),customerNumber);
message = message.Replace("[FirstName]",dtCustomer.Rows[0]["FirstName"].ToString().Trim());
message = message.Replace("[LastName]",dtCustomer.Rows[0]["LastName"].ToString().Trim());
message = message.Replace("[URL]","<a href=" + url + ">" + url + "</a>");
message = message.Replace("[CustomerNumber]",dtCustomer.Rows[0]["CustomerNumber"].ToString().Trim());
message = message.Replace("[Password]",dtCustomer.Rows[0]["Password"].ToString().Trim());
EmailUtility utility = new EmailUtility();
utility.FromAddress = fromAddress;
utility.ToAddress = toAddress;
utility.Subject = subject;
utility.Message = message;
utility.Send();
lblMessage.Text = result;
ReturnAllControls();
}
ReturnAllControls();
}
catch(Exception ex)
{
Response.Redirect("printexception.aspx?appname=" + "PremierSurveyCustomerArea" + "&pagename=Signup" + "&eventname=btnAddCustomer_Click" + "&msg=" + ex.Message,false);
}
}
Any ideas??
Thanks.
-
Mar 26th, 2007, 10:17 AM
#2
Re: Redirect URI cannot contain newline characters
Not even the redirect in the catch{} block?
-
Mar 26th, 2007, 10:21 AM
#3
Thread Starter
Frenzied Member
Re: Redirect URI cannot contain newline characters
Excluding the catch block
I put the function in a try catch block to redirect the user to the error page and get the email notification of the exception from that page. If I comment out the catch block Response.Redirect line, there error is still there.
Thanks.
-
Mar 26th, 2007, 10:24 AM
#4
Re: Redirect URI cannot contain newline characters
Nothing I can see that would obviously do it. Have you tried stepping through it and watching you response headers?
-
Mar 26th, 2007, 10:25 AM
#5
Thread Starter
Frenzied Member
Re: Redirect URI cannot contain newline characters
I am not getting the error on my local windows 2000 machine. I am getting this exception when I uploaded the application to windows 2003 server.
Thanks.
-
Mar 27th, 2007, 08:10 AM
#6
Re: Redirect URI cannot contain newline characters
What does ReturnAllControls do? Why are there two calls to it?
I think you should use trace statements in your code then. Placing them at appropriate points in code should help you narrow down the area where it occurs. Execute the page, get the error, then look at trace.axd to see the messages or the point which execution did reach.
-
Mar 27th, 2007, 08:16 AM
#7
Thread Starter
Frenzied Member
Re: Redirect URI cannot contain newline characters
The page is AJAX enabled, so ReturnAllControls() simply returns some controls that need to be refreshed. Yes, the two occurrences are wrong, I'll get rid of one, here's the method.
Code:
private void ReturnAllControls()
{
try
{
ReturnControls.Add(txtFirstName);
ReturnControls.Add(txtLastName);
ReturnControls.Add(txtPassword);
ReturnControls.Add(txtConfirmPassword);
ReturnControls.Add(txtEmail);
ReturnControls.Add(txtCompanyName);
ReturnControls.Add(txtPhoneNumber);
ReturnControls.Add(txtCellNumber);
ReturnControls.Add(txtAddress);
ReturnControls.Add(txtCity);
ReturnControls.Add(txtState);
ReturnControls.Add(txtZipCode);
ReturnControls.Add(cboCountries);
ReturnControls.Add(lblMessage);
}
catch(Exception ex)
{
Response.Redirect("printexception.aspx?appname=" + "PremierSurveyCustomerArea" + "&pagename=Signup" + "&eventname=ReturnAllControls" + "&msg=" + ex.Message,false);
}
}
I will try to trace the error but I am not so sure why it is giving error for Redirect URI when the page is not redirecting anywhere (in normal execution).
Thanks.
-
Mar 27th, 2007, 02:00 PM
#8
Re: Redirect URI cannot contain newline characters
And there is your problem. It's (probably) quite simple really.
An exception is being caught. You attempt to redirect to printexception.aspx and also pass the Exception message in the querystring. Consider that the ex.Message actually contains some newline characters, and that is your problem.
Move the ex.Message into some other information persisting object such as context variables or session variables and read it on printerror.aspx.
-
Mar 28th, 2007, 05:29 AM
#9
Thread Starter
Frenzied Member
Re: Redirect URI cannot contain newline characters
You were right....There was an exception in the method and that exception contained invalid characters, so the Response.Redirect blew up.
Thanks.
-
Mar 28th, 2007, 10:56 AM
#10
Re: [RESOLVED] Redirect URI cannot contain newline characters
No prob.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|