smacca
asked on
WebException when trying to retrieve HTML created from another ASPX page.
Hi,
I am receiving a WebException when I post and retrieve HTML from an ASPX Page.
The page is responsible for creating a branded email:
http://www.hesgroup.com.au/email/emailtemplate.aspx
The following fields are posted to it:
string toName = string.IsNullOrEmpty(Reque st.Form["t oName"]) ? String.Empty : Server.UrlDecode(Request.F orm["toNam e"]);
string toEmail = string.IsNullOrEmpty(Reque st.Form["t oEmail"]) ? String.Empty : Server.UrlDecode(Request.F orm["toEma il"]);
string fromName = string.IsNullOrEmpty(Reque st.Form["f romName"]) ? String.Empty : Server.UrlDecode(Request.F orm["fromN ame"]);
string fromEmail = string.IsNullOrEmpty(Reque st.Form["f romEmail"] ) ? String.Empty : Server.UrlDecode(Request.F orm["fromE mail"]);
string subject = string.IsNullOrEmpty(Reque st.Form["s ubject"]) ? String.Empty : Server.UrlDecode(Request.F orm["subje ct"]);
string message = string.IsNullOrEmpty(Reque st.Form["m essage"]) ? String.Empty : Server.UrlDecode(Request.F orm["messa ge"]);
The error being returned is a 500 server error and does not help me in anyway debug.
I am also retrieving the exception details (see code below) to help with debug but still cannot resolve:
I have attached all the code (in a zip file) needed to reproduce error including a 'Contact Us' page that will post fields to page creating the email.
In summary, this page posts to the email template, and then retrieves the HTML and sends the HTML by email to customer and client.
This library has never failed me until this project and I cannot seem to resolve.
My money is on an OVERFLOW error in the byte code when adding post keys.
Would love a HTTP expert to help with this - any help appreciated.
SHOULD BE EASY TO RUN ALL FILES!!
Thanks for your time.
I am receiving a WebException when I post and retrieve HTML from an ASPX Page.
The page is responsible for creating a branded email:
http://www.hesgroup.com.au/email/emailtemplate.aspx
The following fields are posted to it:
string toName = string.IsNullOrEmpty(Reque
string toEmail = string.IsNullOrEmpty(Reque
string fromName = string.IsNullOrEmpty(Reque
string fromEmail = string.IsNullOrEmpty(Reque
string subject = string.IsNullOrEmpty(Reque
string message = string.IsNullOrEmpty(Reque
The error being returned is a 500 server error and does not help me in anyway debug.
I am also retrieving the exception details (see code below) to help with debug but still cannot resolve:
I have attached all the code (in a zip file) needed to reproduce error including a 'Contact Us' page that will post fields to page creating the email.
In summary, this page posts to the email template, and then retrieves the HTML and sends the HTML by email to customer and client.
This library has never failed me until this project and I cannot seem to resolve.
My money is on an OVERFLOW error in the byte code when adding post keys.
Would love a HTTP expert to help with this - any help appreciated.
SHOULD BE EASY TO RUN ALL FILES!!
Thanks for your time.
----------------------
string toName = string.IsNullOrEmpty(Request.Form["toName"]) ? String.Empty : Server.UrlDecode(Request.Form["toName"]);
string toEmail = string.IsNullOrEmpty(Request.Form["toEmail"]) ? String.Empty : Server.UrlDecode(Request.Form["toEmail"]);
string fromName = string.IsNullOrEmpty(Request.Form["fromName"]) ? String.Empty : Server.UrlDecode(Request.Form["fromName"]);
string fromEmail = string.IsNullOrEmpty(Request.Form["fromEmail"]) ? String.Empty : Server.UrlDecode(Request.Form["fromEmail"]);
string subject = string.IsNullOrEmpty(Request.Form["subject"]) ? String.Empty : Server.UrlDecode(Request.Form["subject"]);
string message = string.IsNullOrEmpty(Request.Form["message"]) ? String.Empty : Server.UrlDecode(Request.Form["message"]);
------------------------------------------
catch (WebException wex)
{
if (this._doThrowExceptions)
throw wex;
if (wex.Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse response = wex.Response as HttpWebResponse;
if (response != null)
{
this._errorMessage = "HttpWebResponse.StatusCode=" + response.StatusCode + "|HttpWebResponse.StatusDescription=" + response.StatusDescription + "|" + wex.Message;
}
}
else
{
this._errorMessage = wex.Message;
}
this._hasError = true;
return null;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER