如果我以某种形式onClick
按钮(btnConverttoPDF
),它会
使用表单中的所有内容创建PDF ..
它在本地工作正常..但是当应用程序部署在服务器中时 它引发了一个错误..如下
“无法建立连接,因为目标计算机是主动的 拒绝它127.0.0.15:55374“WebException:无法连接到 删除服务器并提及文件的路径 E:\主\ OnlineSite \ OnlineBanking \ ClosingBalance.aspx.cs
刚才我发现了这个问题......
图像控件在
期间导致问题htmlparser.Parse(SR);
以下是我尝试过的代码
protected void btnconvert_Click(object sender, EventArgs e)
{
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
//To Export all pages
grdLast10trans.AllowPaging = false;
BindGrid(); //Calling a Function, here im adding the data to the Datasource and diplaying in Grid
content.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A3, 10f, 10f, 10f, 10f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
//pdfDoc.NewPage();
htmlparser.Parse(sr); //Here it's causing error b'coz of image contol
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
}
}