Thank you very much for helping me, I commented that I could finally do what I wanted to put the code in case someone someday needs this:
public ActionResult CreatorPDF(string consecutive)
{
Dictionary<string, string> cookieCollection = new Dictionary<string, string>();
foreach (var key in Request.Cookies.AllKeys)
{
cookieCollection.Add(key, Request.Cookies.Get(key).Value);
}
string nameFile = consecutive.ToLower().Contains("cot") ? string.Format("{0}.pdf", consecutive) :
string.Format("{0}-{1}.pdf",ConfigurationManager.AppSettings["PrefixEstablishment"],consecutive);
var pdf = new ActionAsPdf(string.Format("OrderInvoice/{0}", consecutive)) {
Cookies = cookieCollection,
PageSize =Rotativa.Options.Size.A4,
CustomSwitches = "--print-media-type",
PageMargins = {Left=1,Right=1},
FileName = nameFile,
};
return pdf;
}
observations:
* the foreach, keeps the active session when generating the pdf, this prevents it from generating a pdf of the login page
* the variable string nameFile can be ignored is something I have put to verify if the user generates a quote or a real invoice
Ready that's all boys.