将Pdf从托管应用程序导出到本地计算机 [英] Export Pdf from a hosted application to a local machine

查看:96
本文介绍了将Pdf从托管应用程序导出到本地计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试使用此代码将我在goddady托管的网站上的pdf文件导出到我的本地计算机:

Hi I am trying to export pdf file from my website hosted in goddady to my local machine by using this code :

protected void ExportPDF_Onclick(object sender, EventArgs e)
   {
                Response.ContentType = "application/pdf";
               Response.AddHeader("content-disposition", "attachment;filename=OrderDetails.pdf");
               Response.Cache.SetCacheability(HttpCacheability.NoCache);
               StringWriter sw = new StringWriter();
               HtmlTextWriter tw = new HtmlTextWriter(sw);
               this.Page.RenderControl(tw);
               StringReader sr = new StringReader(sw.ToString());
               Document Orderpdf = new Document(PageSize.A4, 10f, 10f, 0f, 0.0f);
               HTMLWorker htmlparser = new HTMLWorker(Orderpdf);
               PdfWriter.GetInstance(Orderpdf, Response.OutputStream);
               Orderpdf.Open();
               htmlparser.Parse(sr);
               Orderpdf.Close();
               Response.Write(Orderpdf);

               Response.End();
   }



然后按下导出按钮后,我看到了这个错误:

Parser错误消息:此配置节不能在此路径中使用。当站点管理员使用< location allowOverride =false>锁定对此部分的访问权限时会发生这种情况。来自继承的配置文件。



因为我在描述之前收到此错误:应用程序试图执行操作而不是

允许安全政策。要授予此应用程序

所需的权限,请联系您的系统管理员或更改

应用程序在配置文件中的信任级别。

异常详细信息: System.Security.SecurityException:那个程序集

不允许部分信任的调用者。



然后我用托管信任改变了我的web.config文件水平,但我仍然得到该分析器错误消息。请有人帮助修复。


Then after hitting the export button as u see it,I am getting this error:
Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.

because I was getting this error before Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the
required permission please contact your system administrator or change
the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: That assembly
does not allow partially trusted callers.

Then I changed my web.config file with hosting trust level but I am still getting that Parser Error Message.Please can someone help fixing.

推荐答案





http://www.dotnetfunda。 com / forums / thread3982-this-configuration-section-not-used-at-this-path.aspx [ ^ ]



http://stackoverflow.com/questions/9794985/iis-this-configuration-section-cannot -be-used-at-this-path-configuration-lock [ ^ ]


这篇关于将Pdf从托管应用程序导出到本地计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆