简体   繁体   中英

Using custom settings for WebBrowser Control

I'm trying to build an c# application that uses the WebBrowser Control for, obviouly, webbrowsing. To enhance the security of the system, i'd like to set my own security settings. These are two of the settings i would like to set through the software:

  1. Disable Download for certain file-extensions (*.exe)
  2. Disable Cookies

I found, that the WebBrowser Class directly uses the settings from Internet Explorer. Is there any way to use own settings for a specific WebBrower or overide these settings (maybe just temporarely)?

I think the Question may be similar to this:
Overriding IE settings when embedding a WebBrowser control using IE9
(But i'm not sure... :)

EDIT: If I change the Cookie-Settings for Internet Explorer, they will be used for my WebBrowser-Control, right? Is it possible to change these global Settings via C#? Maybe this could be an easy solution for the Problem...

Unfortunately, it doesn't look like you can disable cookies, though you can clear them; however, when you do so, you will be clearing cookies for all IE instances on that PC (for that particular account). Here is a StackOverflow with more detail .

As far as controlling which files may be downloaded, you probably need to use some form of the FileIOPermission Class. Here is a StackOverflow expanding on that with an example in the answer .

Last, explore the MSDN documentation for the Webbrowser control class, and you might get closer to what you need.

Good Luck!

You can adjust which files that can be downloaded by using the Navigating event of a webbrowser...

For Example, in the "Navigating" event for your web browser control...

if (e.Url.ToString().EndsWith(".exe"))
{
    e.Cancel = true;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM