【问题标题】:Rotativa PDF authorization issues for header and footer页眉和页脚的 Rotativa PDF 授权问题
【发布时间】:2016-06-14 19:52:19
【问题描述】:

我通过 Rotativa 创建了一个 PDF,我需要为每个页面添加动态页眉和页脚。所以我使用视图来显示页眉和页脚。

下面是代码:-

string customswitch = string.Format("--allow {0} --footer-html {0} --allow {1} --header-html {1}",
                    Url.Action("Footer", "Home", new { area = "" }, "http"), Url.Action("Header", "Home", new { area = "" }, "http"));
    [AllowAnonymous]
    public ActionResult Footer()
    {

        return View();
    }


    [AllowAnonymous]
    public ActionResult Header()
    {

        return View();
    }

它在本地运行良好,但在部署之后。我看不到页眉和页脚。我在 IIS 上使用 Windows 身份验证,如果我启用了我不想启用的匿名身份验证,我只能在服务器上看到 HEADER 和 FOOTER。 您能否建议任何解决此问题的方法。

【问题讨论】:

    标签: asp.net-mvc wkhtmltopdf rotativa


    【解决方案1】:

    你试过了吗

    foreach (var key in Request.Cookies.AllKeys)
                {
    
                    CookieCollection.Add(key, Request.Cookies.Get(key).Value);
                }
    
    return new ViewAsPdf(viewName, model)
                    {
                        FileName = fileName,
                        CustomSwitches = customSwitches,
                        Cookies = CookieCollection,                    
                    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-03
      • 2021-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多