Hello all;
I have the following code to fetch an html template (via a webrequest) from an aspx page I have and then print the results of the fetch onto the calling page.
It runs fine on my local and test servers, however, as soon as I put it live it gives me the following error:
Does anybody know what could be causing this error?
I am stumped. :-(
Thank you for any and all help/advice/guidance.
Sean.![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)
I have the following code to fetch an html template (via a webrequest) from an aspx page I have and then print the results of the fetch onto the calling page.
Code:
// First get the newsletter template
string sImageUrl = "";
NewsTemp oNewsTemp = NewsTemp.Get(int.Parse(Request["tem_Id"].ToString()));
string sUrl = General.GetBaseUrl(Request.ServerVariables["SERVER_NAME"].ToString()) + "templates/newsletters/" + oNewsTemp._sFilename;
sUrl += "?type=preview";
if (Request["img_Id"].ToString().Length > 0)
{
sUrl += "&img_Id=" + Request["img_Id"].ToString();
}
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream st = resp.GetResponseStream();
StreamReader sr = new StreamReader(st);
string buffer = sr.ReadToEnd();
sr.Close();
st.Close();
string sJavascript = "\n\n<script type=\"text/javascript\"> \n" +
"var obj = window.opener; \n" +
"var title = obj.document.getElementById('ctl00_MainContent_txtTitle').value; \n" +
"var imgtext = obj.document.getElementById('ctl00_MainContent_txtImageText').value; \n" +
"var body = obj.document.getElementById('fckBody').value; \n" +
"document.getElementById('spnTitle').innerHTML = title; \n" +
"document.getElementById('spnImageText').innerHTML = imgtext.toUpperCase(); \n" +
"document.getElementById('spnText').innerHTML = body; \n" +
"</script>";
buffer += sJavascript;
Page.Response.Write(buffer);
It runs fine on my local and test servers, however, as soon as I put it live it gives me the following error:
No connection could be made because the target machine actively refused it
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
Source error:
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Does anybody know what could be causing this error?
I am stumped. :-(
Thank you for any and all help/advice/guidance.
Sean.
![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)