How to invoke the default browser with an URL from C#?
System.Diagnostics.Process.Start("http://www.google.com");
More details here -
http://msdn.microsoft.com/en-us/library/aa326951.aspx
System.Diagnostics.Process.Start("http://mysite.com");
I used System.Diagnostics.Process.Start in the past, but if Firefox or another browser is set as the default this method always throws a terrible exception to users. At last, I come across System.Windows.Forms.Help.ShowHelp
Help.ShowHelp(null, "http://www.google.com");
Please notice that Help is a class only available for WinForms, while Process can be used for other cases (WebForms, WPF and so on).
Related
i have a scenario in which i want to set a page redirection from a custom url to my web site.For instance i might want http://support.mydomain.com to open page http://mysubdomain.mydomain.com/support/index.aspx but the trick is that i want the address bar to show http://support.mydomain.com and not http://mysubdomain.mydomain.com/support/index.aspx. I m using aspnet c# web forms.
Any ideas?
It doesn't sound good especially if its on your subdomain. However the answer would be to use an Iframe.
You can try using URL Rewrite. Even though, strictly speaking, it is a workaround.
You can use
Server.Transfer()
Because it doesn't change the url bar. Also
The best thing is using
Configure Url Rewrite in IIS
Is the website able to determine if a particular IE add on has been installed or not?
How do you have the web page detect the IE add on?
In general, no; however it depends on what the add-on does. If it modifies the web page in some way (e.g. removing ads) then it should be possible to use Javascript to detect if the current page has been modified.
If the addon is available via Javascript/ActiveX interface, its absense may be checked by catching an exception on calling some (missing) addon's function.
This way, checking for few common addons leads to nice browser's fingerprinting method.
Refer to: http://www.informatica64.com/Wbfingerprinting/
No doubt you can detect most through JavaScript; it'd be addon-specific.
In IE just expose an Active X control from your add-on, and then instantiate it using new ActiveXControl() inside a Javascript try {} block. If it succeeds, your extension is installed. If it fails, probably not. You can even expose a .version() method to get the version of the control.
I use the WebBrowser component from WPF. I load there a page from Internet and I access the Document property to call my scripts. Unfortunately calling scripts don't work as I need. When I am calling JavaScript methods which exist in JavaScript so it works great but when I need access some methods which are available through Flash so I have problems.
document.parentWindow.execScript("document.getElementById('swfObject').methodFromActionScript();", "JavaScript");
I get an exception in the browser Object doesn't support this property or method. In C# I get Exception from HRESULT: 0x80020101
But when I try launch this code in a regular browser as IE or Chrome by passing it into URL so the code is executed and I see results.
Maybe some trustmode issues or what else could deny access to Flash properties and methods?
BTW: The var allowScriptAccess is set to always.
Thank you for help.
Ok, I've found an issue. Before this execScript. I was doing some modification of DOM and moving elements and apparently this has broken DOM so I couldn't call swfObject because during moving it was somehow modified and lost its properties and methods which were exported via ActionScript.
How to access the elements within an in WebBrowser in C#.NET?
try this
webBrowser1.Document.GetElementById("idName").SetAttribute("value") = "ddddd" ;
var stuff=webBrowser1.Document.GetElementById("idName").GetAttribute("attribute");
it works for me when I need to get/set control data and get any html element value
Generally, you can't. C# and .NET are typically used in frameworks like ASP.NET to produce the content that is consumed by the browser. This happens on the server-side.
If .NET is installed on the client, then you can host a Windows Forms control in an HTML document in Internet Explorer but this is very, very non-standard, and I'd advise heavily against doing so.
As far as I understand you can access the controls inside the webbroswer control using the following code
WebBrowser1.Document.GetElementById("controlId").
Is this what you are looking for?
Additionally this discussion in daniweb might be of some interest to you.
I need to create and add custom headers to an ASP.NET 2.0 application.
The case is simulation of an SSO-login in our dev/test environment.
When I try to add headers I run into the "Not supported on this platform."
error. BigJim has a nice post on the subject here:
http://bigjimindc.blogspot.com/2007/07/ms-kb928365-aspnet-requestheadersadd.html
The root of my problem lies in the fact that I need to simulate various
persons logging into my application. Not just adding static data in a
HttpModule. I need to take values from a couple of TextBoxes and transfer
information from these into custom headers and then re-direct the user. The
HttpModule stuff happens to early in the pipeline...
Does anyone now if there exsist a simple redirect/proxy solution that one
could use in a dev environment? Or have simple/beautiful way of doing it in code?
One method i have used before, though a long winded approach, is NUnitASP.
This is based on the NUnit framework but intended for ASP.NET UI Testing.
It basically starts a browser in memory, and is able to manipulate the content exactly like a user would.
Using this you could view your page, enter data into textboxes and submit pages.
Hopefully that can help you do the testing you require. I've used it to test load, and spider through sites of mine to gather data.
If you use IIS 7 you can set the Pipeline Mode to integrated
This Setting is found in the App-Pool Properties.
I could be wrong, but doesn't the Response.AddHeader() method still work? Although, I agree with Oscar that a formal testing solution like NUnitASP is a good idea. Although, NUnitASP is a little dated. I still use it for some of my projects just because it still does work; it just isn't as refined or as simple as WaTiN or similar projects.
The browser drops the header if you do a Response.AddHeader()...
The header must be added to the orginal Request...
why don't use ASP.NET forms authentication model?
you define your "private folders". if you attempt to acces to a private folder without login, you automatically are redirected to a your custom login page.
here's a couple of link:
http://support.microsoft.com/kb/301240
http://www.asp.net/learn/security/tutorial-02-cs.aspx