Asp.net mvc 页眉和页脚的Rotativa PDF授权问题
我已经通过Rotativa创建了一个PDF,我需要在它的每个页面动态页眉和页脚。所以我使用视图来显示页眉和页脚 代码如下:-Asp.net mvc 页眉和页脚的Rotativa PDF授权问题,asp.net-mvc,wkhtmltopdf,rotativa,Asp.net Mvc,Wkhtmltopdf,Rotativa,我已经通过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(
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身份验证,如果启用匿名身份验证,我只能在服务器上看到页眉和页脚,我不想这样做。
您能否建议解决此问题的方法。您尝试过吗
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,
};
你试过了吗
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,
};