Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Can PDF file Download - Open opens the file in another tab with URL file://// (instead of opens it in Adobe Reader) ?

$
0
0
With the below codes, in Chrome it shows the Download file, and when you select "Open", it opens it in a new Chrome tab with the URLfile:///C:/Users/myNetworkUserID/Downloads/myFile.pdf.
But, in Internet Explorer, it shows the Download file, and when you select "Open", it opens it in Adobe Reader.
In Internet Explorer, when I select "Open", can I open it in a new Internet Explorer tab with the URLfile:///C:/Users/myNetworkUserID/Downloads/myFile.pdf (just like in Chrome) ? Thank you.
This is from the View:
@{
ViewBag.Title = "Archive";
var X = Html.X();
}
@section Scripts
{<script type="text/javascript">
        var Test2 = function () {
            var sSelection = getselection();
            return window.open('/Archive/Save2?selection=' + sSelection);
        }</script>
}
@section SPAViews { @( X.Viewport().Layout(LayoutType.Fit).Items( X.TabPanel().ID("ArchiveTabPanel") .Items( X.GridPanel().ID("GridPanel1").MarginSpec("1 1 1 1").Cls("cust-grid").Title("Archive").Icon(Icon.ServerCompressed) .Plugins(X.GridFilters()) .View(Html.X().GridView().StripeRows(true).TrackOver(false)) .SelectionModel(X.CheckboxSelectionModel().Mode(SelectionMode.Multi)) .TopBar( X.Toolbar().MinHeight(35) .Items( : , X.Button().Text("Testing2").Icon(Icon.DiskDownload).Handler("Test2();")
This is in the Archive controller:
public ActionResult Save2(string selection)
{
  Byte[] pdf = ArcTicketByte(0);
  string file = Server.MapPath("~/Test.pdf");
  using (FileStream fs1 = System.IO.File.Create(file))
  {
     fs1.Write(pdf, 0, pdf.Length);
  }

  System.Net.Mime.ContentDisposition cd = new      System.Net.Mime.ContentDisposition
  {
     FileName = file,
     Inline = false  // false = prompt the user for   downloading;  true = browser to try to show the file inline
   };
   Response.Headers.Add("Content-Disposition", cd.ToString());
   Response.Headers.Add("X-Content-Type-Options", "nosniff");

   return File(pdf, "application/pdf");
}


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>