Visual Studio C# hyperlink loads in browser AND in .net app - c#

I have a VS 2010 .net app with a hyperlink within a textblock within a stackpanel on a .XAML. When I run the app it opens the link in a new tab in IE which is great, it's exactly what I want. But it also opens it in the executing app panel. I can navigate away and back and get back to the page in my app that I was working on but I need to keep it from loading on that page to begin with. Otherwise the behavior is exactly what I want. Note: I tried using the AbsoluteUri line that is commented out but that had the same behavior PLUS would shut the app down. Thanks in advance.
<Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="http://www.msn.com">Click here to go to msn</Hyperlink></TextBlock>
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
// System.Diagnostics.Process.Start(e.Uri.AbsoluteUri);
System.Diagnostics.Process.Start("http://www.msn.com");
} ```

Related

WebBrowser control throwing lots of JavaScript errors

The WebBrowser control shipped with .NET 4.7 is throwing lots of JavaScript errors. For example, we tried with www.yahoo.com and we get multiple JavaScript errors. One such example is shown below:
If we browse the same link in internet explorer 11, we are not getting any error and browsing session goes smooth. Note that we already set Browser Emulation registry setting for IE 11. Used the Link to Set IE 11 Emulation. The Registry Key for the Emulation is:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
(For 64 bit machine)
Re-production steps
Create a Visual C# Windows Forms Application
Place Web-Browser Control and a Command Button in the Form
Add the Following code in the command button Handler:
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.yahoo.com");
}
That is all. Once we click the command button, we have to respond to multiple JavaScript errors. How do we resolve this issue?
Note that we already have Browser Emulation for IE is set to 11 (in Registry). We do not want to suppress the Error, as we lose the service provided by the JavaScript. For example, click the “Cricket” button in the very top of the Yahoo page:

How to create a UWP application which only opens a specific url

I want to create a UWP application which only opens a specific url in the browser. So I mean that this app will have an icon in the start menu but when a user clicks this icon nothing happens but only my url is opened in the browser. Is it possible? How to implement such UWP application?
I created an App class and in OnLaunched method I wrote this code:
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
var task = Windows.System.Launcher.LaunchUriAsync(new Uri("https://stackoverflow.com")).AsTask();
task.Wait();
CoreApplication.Exit();
}
This works fine. The only problem is that white window of my app is opened and closed after about 1 second.
Update 1:
The main purpose of my app is to work as an appservice. Another component of my system successfully communicates with it. If it is possible not to show the icon in the start menu at all it would be great solution. However, I don't know how to hide my app from the start menu. So another appropriate solution for me is just to open the url of my specific web site without showing a splash window once a user clicks the icon in the start menu.
I don't care about certification in the store.
Even if you can successfully implement such behavior, the app window and splash screen will still display (even if just for a while) and the app will definitely not pass Microsoft Store submission (because it exits during launch and it brings no additional value over the website itself)

How can I control the a application from a other form windows application in C#?

I want to make a form Windows application in C# with just a button . when the user click on button the one of Browser google chrome or muzila or explorer become open and show the option or setting page of Browser .
Now I can open the browser with this cods . I need control the Browser for show options or refresh or Stop .
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("chrome.exe") ;
}
If you want to start a specific website the code is:
System.Diagnostics.Process.Start("http://www.webpage.com");
If you want to start a specific browser at a specific website the code is:
System.Diagnostics.Process.Start("iexplore.exe", "http://www.webpage.com");

Launching Internet Explorer using LaunchUriAsync stops the app when running without debugger. No exceptions. What can I do to resolve this?

The below code works when I debug the app. internet explorer loads the uri. No problem there. But when I stop debugging and try it out, the internet explorer does open up with the URI loaded, but the app isn't running anymore. It just stops
private void appBtnOpenInIE_Click(object sender, RoutedEventArgs e)
{
var uri = readingWebView.Source;
var success = Windows.System.Launcher.LaunchUriAsync(uri);
}
appBtnOpenInIE is the SecondaryCommand from which I am trying to load the URI in Internet Explorer
readingWebView is the WebView control I have loaded on the xaml page which has the web page loaded
Note that I am using the exact 2 lines of code in another case where I am loading a URI based on the click of a HyperlinkButton and that works fine too. The app continues to run in the background and Internet Explorer has the URI loaded
Based on the help provided by #Romasz , here is the solution i found
When moving from Page1 to Page2, I was passing an object. The suspension manager wasn't able to serialize that object in the Suspending event handler which was causing the app to terminate. So, instead of passing the object type, I passed a primitive type (int) and it worked without errors

Open Internet Explorer from Google Chrome

I currently developing a ASP.NET web application.
The application is designed for Google Chrome. I would like to pop out IE when printing is involved because Chrome lack preview etc. at a button click the IE should open. Here's the code:
protected void btn_print_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://localhost/storeapp/printpage.aspx?orderno=" + Request.QueryString["orderno"].ToString() + "");
}
Here I have passed a particular orderno to the URL. But when I click nothing happens. I have set IE as default web browser. Why is this?
There is no error shown? Any ideas?
What you are trying to do will only open an IE window on the SERVER not on the client machine. You cannot (for obvious security reasons) start a process on the clients machine.
You cannot force a client browser to open a link in a different browser.
You cannot force server to open process on Client side, what you have now is opening it on the Server side which is not desired behavior I believe.

Categories

Resources