s.s. s.s. - 3 months ago 31
C# Question

open PDF file from cross domain

I would like to open PDF file in a new window on the browser from java script.

But i can't use

window.open
because the file located on cross domain.
I tried do it via controller by
process.Start()
function, and nothing happened

var p = new Process();
p.StartInfo = new ProcessStartInfo(url);
p.StartInfo.WorkingDirectory = Path.GetDirectoryName(url);
p.Start();


(because of my chrome version?)
does anyone have good idea for me??
Thanks a lot!

Answer

If you put the file on your program dirctory then you can use this code

string path = AppDomain.CurrentDomain.BaseDirectory.ToString() + "YourPDF";

and then ou do this

var p = new Process();
        p.StartInfo = new ProcessStartInfo(path);
        p.StartInfo.WorkingDirectory = Path.GetDirectoryName(path);
        p.Start();