Page 1 of 1

Integrate a C# form

Posted: Tue Feb 20, 2018 11:20 am
by Pickeroll
Hey, I'm new to this forum and this environment.

I'm trying to integrate inside a display an external form made with Visual Studio, the file is named Login.application.

The code is basically this:

Code: Select all

private void button1_Click(object sender, EventArgs e)
{
    var menu = webBrowser1.Document.GetElementById("SomeItem").InvokeMember("click");
    webBrowser1.Visible = true;
    button1.Visible = false;
}

private void Form1_Load(object sender, EventArgs e)
{
    webBrowser1.Visible = false;
    webBrowser1.Navigate("someUrl");
}
First of all: is this possible ?

I know that in this environment there is a native integration with JS, but I found some cross origin problems while I was trying to navigate the DOM inside an iframe.

Looking for hints and a smart way to do it.

Thanks for the help.

Re: Integrate a C# form

Posted: Tue Feb 20, 2018 6:58 pm
by Megan
Hello Pickeroll,

Thank you for writing in! Could you please describe what it is you are trying to do with the iFrame in more detail? Perhaps we can help you with your problems navigating the DOM inside an iFrame.

Thanks,

Re: Integrate a C# form

Posted: Wed Feb 21, 2018 9:12 am
by Pickeroll
Megan wrote:Hello Pickeroll,

Thank you for writing in! Could you please describe what it is you are trying to do with the iFrame in more detail? Perhaps we can help you with your problems navigating the DOM inside an iFrame.

Thanks,
Thanks for the reply.
My aim is to integrate a form from an external website, I don't have the direct url of this form so I've put an inframe and tried to access to the DOM of it and navigate with .click() command, the problem was that the DOM of the iframe resulted to be blank.

I've opened some topics on Stackoverflow but the replies weren't encouraging.

https://stackoverflow.com/questions/488 ... javascript

Re: Integrate a C# form

Posted: Wed Feb 21, 2018 3:35 pm
by Scott Klement
I'm not familiar with C#, but I think what you're asking is more related to JavaScript than it is C#, correct? You're inserting JavaScript code into a page that is trying to read the contents of an iframe.

Normally, JavaScript code can only access the contents of a different iframe if it comes from the same "origin" (by "origin", I mean the same host/port.) There is a way to override this, but only if access is granted with special HTTP headers (and I'm not certain whether that is available in all browsers.) You cannot normally access contents in an iframe from a different origin because this would allow rogue web sites to steal your personal information. Since this would be a huge security problem, web browsers specifically look for it and block it.

I've glanced over the StackOverflow link you posted, and it looks like the responder over there said the same thing.

Re: Integrate a C# form

Posted: Thu Feb 22, 2018 5:54 am
by Pickeroll
Scott Klement wrote:I'm not familiar with C#, but I think what you're asking is more related to JavaScript than it is C#, correct? You're inserting JavaScript code into a page that is trying to read the contents of an iframe.

Normally, JavaScript code can only access the contents of a different iframe if it comes from the same "origin" (by "origin", I mean the same host/port.) There is a way to override this, but only if access is granted with special HTTP headers (and I'm not certain whether that is available in all browsers.) You cannot normally access contents in an iframe from a different origin because this would allow rogue web sites to steal your personal information. Since this would be a huge security problem, web browsers specifically look for it and block it.

I've glanced over the StackOverflow link you posted, and it looks like the responder over there said the same thing.
Thanks for your reply Scott.
Javascript was as a matter of fact my first try, but then I run into the problems described by you and the StackOverflow community.

So:
- I created a Windows Form Application
- Installed it on my Server (it works)
Image
- Tried to Run it following this page: http://www.profoundlogic.com/docs/pages ... d=26607685
- I tried by using this notation:

Code: Select all

var command = "C://Users//filip//Desktop//Taric//Login.Application"; -> or Setup.exe
pui.runPCCommand(command);  
or by calling directly:

Code: Select all

pui.runPCCommand("Login"); -> "Login.Application" -> "Setup.exe"
I tried also with the example but no windows alert appeared, so maybe I'm missing something.
Image

Re: Integrate a C# form

Posted: Thu Feb 22, 2018 7:04 am
by Pickeroll
Now following the Desktop path I successfully launched the application, but It works only one time then in order to launch it again I need to clean my cookies.

Re: Integrate a C# form

Posted: Thu Feb 22, 2018 3:25 pm
by Scott Klement
Hi Pickeroll,

Previously you were referring to running a web page in a separate iframe.

Now you are showing me the path to a Windows program, so I am getting confused. Is this a separate question? Or have you replaced the web page with a Windows program?

The pui.runPCCommand() runs a Windows command, so needs to be in the syntax that Windows expects it. Some of your earlier examples are using foreslashes (the "/" character) in the path, and I don't think Windows supports that. The final example (in the screenshot of the Subfile Row Onclick event) correctly uses the backslash ("\" character) and it looks like it should work.

You mentioned something about clearing cookies, and I don't understand why that would matter. pui.runPCCommand() does not use cookies at all.

Perhaps it would help if you explained how you are running this? Are you using the PC Command Launcher? The PC Command Listener? or the Java applet?