C# 云web服务器上的wkhtmltopdf.exe System.Security.SecurityException。如何覆盖服务器安全策略

C# 云web服务器上的wkhtmltopdf.exe System.Security.SecurityException。如何覆盖服务器安全策略,c#,asp.net,wkhtmltopdf,C#,Asp.net,Wkhtmltopdf,我想为我的网站有一个功能,可以打印为PDF格式的页面内容。我为此尝试了一些选项,但最好的匹配是wkhtmltopdf,因为它也处理多语言字符 我让它在我的本地服务器上工作,但当我把它上传到云web服务器上进行托管时,它给了我以下错误 Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this

我想为我的网站有一个功能,可以打印为PDF格式的页面内容。我为此尝试了一些选项,但最好的匹配是wkhtmltopdf,因为它也处理多语言字符

我让它在我的本地服务器上工作,但当我把它上传到云web服务器上进行托管时,它给了我以下错误

Security Exception
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: Request failed.
我在web.config中将安全策略更改为

<securityPolicy>
  <trustLevel name="Full" policyFile="internal"/>
</securityPolicy>

工作代码: 我通过从MainPage.aspx调用PrintArticle.aspx解决了这个问题,当用户点击LNKBTNLoad链接按钮时,它将调用页面PrinteArticle.aspx(打印文章页面是一个显示文章标题、日期和文章描述的简单页面)并将HTML传递给下面的代码,然后将其打印为PDF文件

   protected void lnkbtnDownload_Click(object sender, EventArgs e)
    {
        string url = "PrintArticle.aspx?articleID=" + Request["articleID"] + "&download=yes&Language=" + Request["Language"];

        string args = string.Format("\"{0}\" - ", "http://xyz.net/" + url);
        var startInfo = new ProcessStartInfo(Server.MapPath("bin\\wkhtmltopdf.exe"), args)
        {
            UseShellExecute = false,
            CreateNoWindow = true,
            RedirectStandardOutput = true

        };
        var proc = new Process { StartInfo = startInfo };
        proc.Start();

        string output = proc.StandardOutput.ReadToEnd();
        byte[] buffer = proc.StandardOutput.CurrentEncoding.GetBytes(output);
        proc.WaitForExit();
        proc.Close();
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition", "attachment;filename=download.pdf");
        Response.BinaryWrite(buffer);
        Response.End();
    }
我将其他参数作为查询字符串传递,如articleID、Download、Language等

   protected void lnkbtnDownload_Click(object sender, EventArgs e)
    {
        string url = "PrintArticle.aspx?articleID=" + Request["articleID"] + "&download=yes&Language=" + Request["Language"];

        string args = string.Format("\"{0}\" - ", "http://xyz.net/" + url);
        var startInfo = new ProcessStartInfo(Server.MapPath("bin\\wkhtmltopdf.exe"), args)
        {
            UseShellExecute = false,
            CreateNoWindow = true,
            RedirectStandardOutput = true

        };
        var proc = new Process { StartInfo = startInfo };
        proc.Start();

        string output = proc.StandardOutput.ReadToEnd();
        byte[] buffer = proc.StandardOutput.CurrentEncoding.GetBytes(output);
        proc.WaitForExit();
        proc.Close();
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition", "attachment;filename=download.pdf");
        Response.BinaryWrite(buffer);
        Response.End();
    }