I am trying to use a WebBrowser in a .cs class in a Web Application - NOT A WINDOWS FORM app using (VS 2019).
I know it's a Windows Form app control, but it seems like I should be able to use it in a Web App.
Using WebBrowser in Web App does not have the .Url property, so I just use the .Navigate directly - this is where the code breaks.
I have tried many suggestions on the Net, but nothing seems to work - it looks like most of the examples uses a Web Page - I want to use the WebBrowser directly in code (.cs class).
private static void LoginViaUserAgentFlow()
{
Thread thread = new Thread(delegate ()
{
StringBuilder sb = new StringBuilder(String.Format("{0}/services/oauth2/authorize",
RHOutlook.chosenInstance.sfdcURL));
sb.Append("?response_type=token");
sb.Append(String.Format("&client_id={0}", RHOutlook.chosenInstance.clientId));
sb.Append(String.Format("&redirect_uri={0}", System.Web.HttpUtility.UrlEncode(RHOutlook.chosenInstance.redirectUri)));
WebBrowser webBrowserSFDCLogin = new WebBrowser();
//Here I can't use the .Url becaue it is not available - so I just use
//Navigate to get to the site
webBrowserSFDCLogin.Url = new Uri(sb.ToString());
//This is were it breaks, comes back with error when I navigate to the site.
webBrowserSFDCLogin.Navigate(sb.ToString());
//This code is never reached - failed at above code.
if (webBrowserSFDCLogin.LocationURL != null && webBrowserSFDCLogin.LocationURL.StartsWith(RHOutlook.chosenInstance.redirectUri))
{
//webBrowserSFDCLogin.ScriptErrorsSuppressed = true;
webBrowserSFDCLogin.Stop();
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
I expect to be able to navigate to the external website. If I can navigate to the site if I copy the url directly in a browser (say Chrome).
I tried using ; this gives me the Url property, but still get the error.
You really should stick to suggestions and examples.
What you are trying to do is to use class that is designed for Windows Application inside a Web Application.
Those two frameworks are similar like Earth and Mars. I am afraid you are not going to be able to grow a tree on Mars.
Related
How to run same page in browser, when I stopping and re running a page its displaying in new tab and i don't want to display in new tab and I want to display in same page and I'm working on windows form application in c# .net.
Can u please suggest me any one.
The below code I have written like this way.
Process.Start("microsoft-edge:http://www.google.com");
Process[] Edge = Process.GetProcessesByName("MicrosoftEdge");
foreach (Process Item in Edge)
{
try
{
Item.Kill();
Item.WaitForExit(100);
}
catch (Exception)
{
}
}.
Based on my research, I could not find a way to use Process to display the same page in the Edge.
However, I find a alternative method to do it.
First, please install nuget-package Selenium.WebDriver and Selenium.WebDriver.MSEdgeDriver.
Second, please copy the msedgedriver.exe from the packages (path:packages\Selenium.WebDriver.MSEdgeDriver.91.0.864.37\driver\win64)to the bin\debug folder and rename it to MicrosoftWebDriver.exe
Finally, you could try the following code to open the Google page to replace the Bing Page in the same tab:
var driver = new EdgeDriver();
// Navigate to Bing
driver.Url = "https://www.bing.com/";
driver.Navigate();
// Navigate to Google
driver.Url = "https://www.google.com/";
driver.Navigate();
I've got a webpage I want to hook in to my Adobe Air app. It's running JavaScript, so I can't open it in the app, but I'm trying to launch it in the default system browser.
Here's the code that's supposed to be launching the page:
public function beginModule():void {
var loader:HTMLLoader = new HTMLLoader();
var gameURL:URLRequest = new URLRequest("file:///path/to/file.html");
loader.navigateInSystemBrowser = true;
loader.load(gameURL);
}
I've also tried using
flash.net.navigateToURL(gameURL);
but that had no effect.
Every time I hit the above method, that block executes but nothing happens other than a quick cursor change-- no browser opened, no change in the app. What am I missing here?
Before you start, check if the HTML page is properly running in the browser.
To open a HTML page in flex, use the HTML tag: <mx:HTML></mx:HTML>
Something like this: https://snipt.net/anishnair/flex-show-html-page/?key=28838d54ac287180032dee000ce33a74
Thank you.
Regards,
Anish
Simply use :
navigateToURL(url,"_blank");
to navigate to the url in the web-browser.
I have a desktop AIR app built with Flex 4.6 and Air 3.5. I use navigateToURL to launch a URL in the default browser, works fine:
var request : URLRequest = new URLRequest ( "http://localhost:8890/test.html" );
var urlVariables : URLVariables = new URLVariables ();
urlVariables['activity'] = "xyz.json";
request.data = urlVariables;
request.method = URLRequestMethod.GET;
navigateToURL(request, "_self");
The app lets the user construct some JSON content (xyz.json), then test it in a test rig (test.html).
The second and subsequent times I do this, I get a new tab (I'm using Chrome). What I want is for it to appear in the same tab as the last one. Note that I've used "_self". If I pass any string I get the same result.
Any help would be appreciated. Thanks.
I dont believe it is possible to force browser to reuse same tab - that would be browser behaviour, not AIR behaviour (ie: you would change the expected behaviour in browser settings; eg: always open content in new tab).
I believe from a desktop app when you invoke NavigateToURL() it will force a new window (container) to launch.
If you can you could create a separate 'receiver' page on the server to receive the data (invisible to the user) Then launch a 'viewer' page with NavigateToURL that would contain an ajax script to check and update the data received from the 'receiver' page.
I would check out URLLoader() Class. I use this many times for my web service scripts.
i am using custom url scheme in my flex iOS app and it’s working fine when i start my app from a web link..but the issue is when i start my app from start menu in iPad and move to webpage in safari.In page i click a button that redirects it to my app, at that time app call “preinitialize” method more than once..it wary every time, some time it’s 2,3,4 and different one each time..i don't know why it’s behaving like this..can i know the reason please its urgent..
thanks…any help will be appreciated.
Create a flag initialized and set it to true when preinitialize is called. All other calls to this method can be filtered out. Simple example:
private var initialized:Boolean = false;
public function preinitialize():void
{
if (initialized) return;
initialized = true;
}
Next step would be finding the real cause of the multiple calls, but for that we would need to see some code of your app.
I have two flex applications Main.mxml(where I have a button called loadDataViewer) and ViewData.mxml. What I want is when the user press the loadDataViewer button, the application ViewData.mxml will open in a new window. Is there any way to do it in Flex?
SWFLoader class looks interesting but I think it will load the other appliation inside the Main application which I don't want. I also saw that there is ExternalInterfaceAPI which can be used to open a url browser but not sure if I can reference the swf file of VewData application. As suggested here( http://learn.adobe.com/wiki/display/Flex/Local+Connections ) that LocalCOnnection can be used to reference one flex application in another but that's only when both applications are open I guess.
Any suggestion to guide me to the right direction wouild be greatly appreciated.
You could embed your viewData swf to an HTML file, and either do any of the following:
Call External Interface...
var url:String = 'myViewData.html';
ExternalInterface.call('window.open("' + url + '")');
or
Call the navigateToURL method...
var url:String = 'myViewData.html';
var urlReq = new URLRequest(url);
navigateToURL(urlReq,'_blank');
Use Modules. Adobe help.