Print Function using Rotativa

1k views Asked by At

i used Rotativa to print one of my page from html to pdf and when i hit the button to print,it will open print preview,but the preview does not contains that page i just print , it contains and show me log in page in preview instead as you can see,so idont know exactly whats happend.Can someone please point me in the right direction?

The page i tried to print look like this: enter image description here But when i hit the button to print,in preview give me log in page:

enter image description here

AccountController:

protected override void OnActionExecuting(ActionExecutingContext filterContext)
            {
                if (Session["CustomerID"] == null &! Request.RawUrl.ToLower().Contains("login"))
                {
                     Response.Redirect("/Account/Login");
                }
                base.OnActionExecuting(filterContext);
            }

<br>
 //Login


public ActionResult Login()
    {

        return View();

    }
    [HttpPost]
    public ActionResult Login(Customers cust)
    {

        using (DataContext db = new DataContext())
        {
            var user = db.Customers.Where(u => u.CustomerID == cust.CustomerID).FirstOrDefault();

            if (user != null)
            {
                Session["CustomerID"] = user.CustomerID.ToString();
                FormsAuthentication.SetAuthCookie(cust.CustomerID, false);
                Session.Timeout = 30;

                return RedirectToAction("LoggedIn");
            }

            else
            {
                ModelState.AddModelError("", "CustomerID is not Valid");
            }
        }
        return View();

    }

    public ActionResult LoggedIn()
    {

        if (Session["CustomerID"] != null)
        {
            string customerId = Session["CustomerID"].ToString();
            List<Orders> customerOrders;
            using (DataContext data = new DataContext())
            {
                customerOrders = data.Orders.Where(x => x.CustomerID == customerId).ToList();
            }

            return View(customerOrders);
        }
        else
        {
            return RedirectToAction("Login");
        }

    }
    public ActionResult Logout()
    {
        FormsAuthentication.SignOut();
        Session.Remove("Login");
        return RedirectToAction("Login", "Account");
    }

    public ActionResult PrintOrders(int id)
            {
                var report = new ActionAsPdf("ShowOrdersDetails", new { id = id });
                return report;
            }
0

There are 0 answers