Why does Rotativa always generate my login page? Why is it slow?

前端 未结 5 2534
一整个雨季
一整个雨季 2020-12-15 08:24

I was using this Rotativa 1.6.4 code example to generate a PDF from a page in my .NET MVC 5 app.

public ActionResult PrintIndex()
{
    var a = new ActionAsP         


        
5条回答
  •  情深已故
    2020-12-15 09:12

    In my case using UrlAsPdf() along with just adding the cookie that I needed, had resolved the issue. Following is the sample code that I have used.

        var report = new UrlAsPdf(url);
    
        Dictionary cookieCollection = new Dictionary();
        foreach (var key in Request.Cookies.AllKeys)
        {
           if (Crypto.Hash("_user").Equals(key))
           {
              cookieCollection.Add(key, Request.Cookies.Get(key).Value);
              break;
           }
        }
        report.Cookies = cookieCollection;
        report.FormsAuthenticationCookieName = FormsAuthentication.FormsCookieName;
    

提交回复
热议问题