Home How to redirect to homepage ASP.NET MVC
Reply: 0

How to redirect to homepage ASP.NET MVC

missy brown
missy brown Published in 2017-12-07 19:35:26Z

When the user clicks print/issue it produces a pdf file however; I would like the user to open the pdf file in a different tab as well as the current tab redirects to the home page; Because I already have a return; I'm not sure how to redirect to the homepage at the same time. This is what I have thus far

                        <th class="col-md-4">Item Number</th>
                        <th class="col-md-4">Item Description</th>
                        <th class="col-md-4">Expense Account</th>
                        <th class="col-md-2">Quantity Requested</th>
                        <th class="col-md-2">Quantity Issued</th>
                        <th class="col-md-1">UOM</th>
                        <th class="col-md-1">Item Price</th>


                        if (@Model.items.Count > 0)
                            foreach (var issueditem in @Model.items)

                                    <td class="col-md-4">@issueditem.itemNumber</td>
                                    <td class="col-md-4">@issueditem.description</td>
                                    <td class="col-md-4">@issueditem.expense_account.getDescription</td>
                                    <td class="col-md-2">@issueditem.quantity.ToString()</td>
                                    <td class="col-md-2">@issueditem.quantityI.ToString()</td>
                                    <td class="col-md-1">@issueditem.selecteduomtext </td>
                                    <td class="col-md-1">@issueditem.price.ToString()</td>

                                    <td> @Html.ActionLink("Edit", "Edit", new { id = issueditem.lineNum }) </td>





                            <button type="submit" class="btn btn-default" formaction="@Url.Action("ReceiptPrint")">Print/Issue</button>


 public ActionResult ReceiptPrint(Issue issue)
        IssueDAO dbdata = new IssueDAO();
        dbdata.connectionString = ConfigurationManager.ConnectionStrings


        Item item = new Item();

            dbdata.createIssue(getIssue, item);//Creates the issue in the database
        catch (Exception ex)
            LogWrite logWriter = new LogWrite(ex.ToString());
            ViewBag.errorMessage = "Unable to complete the Issue. Please see Log file for more Information";
            return View("Index", getIssue);

        DataSet ds = dbdata.GetReceipt(getIssue.requisitionNumber);

        LocalReport localreport = new LocalReport();
        localreport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\Reciept.rdlc";
        localreport.DataSources.Add(new ReportDataSource("Receipt_Data", ds.Tables[0]));
        localreport.SetParameters(new ReportParameter("Req_num", getIssue.requisitionNumber));

        string reporttype = "PDF";
        string mimeType;
        string encoding;
        string fileNameExtension = "pdf";
        string deviceInfo = @"<DeviceInfo>              
        Warning[] warnings;
        string[] streams;
        byte[] renderedBytes;
        renderedBytes = localreport.Render(
         reporttype, deviceInfo, out mimeType, out encoding, out fileNameExtension,
         out streams, out warnings);

        var doc = new iTextSharp.text.Document();
        var reader = new PdfReader(renderedBytes);
        using (FileStream fs = new FileStream(Server.MapPath("~/Receipt" +
             Convert.ToString(Session["CurrentUserName"]) + ".pdf"), FileMode.Create))
            PdfStamper stamper = new PdfStamper(reader, fs);
            string Printer = "Xerox Phaser 3635MFP PCL6";
            // This is the script for automatically printing the pdf in acrobat viewer
            stamper.JavaScript = "var pp = getPrintParams();pp.interactive =pp.constants.interactionLevel.automatic; pp.printerName = " +
                           Printer + ";print(pp);\r";
        FileStream fss = new FileStream(Server.MapPath("~/Receipt.pdf"), FileMode.Open);
        byte[] bytes = new byte[fss.Length];
        fss.Read(bytes, 0, Convert.ToInt32(fss.Length));
        return File(bytes, "application/pdf");

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30584 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO