Access denied in WebBrowser control
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Access denied in WebBrowser control

  1. #1
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Access denied in WebBrowser control

    I had the "smart" idea of replacing a RichTextBox control with a Webbrowser control, (never worked with html), so I created this class:
    Code:
    Imports System.IO
    Imports System.Web
    
    Friend Class MyBrowser
        Inherits WebBrowser
    
        Friend Shadows WriteOnly Property Texto() As String
            Set(ByVal value As String)
                DocumentText = value.Replace(vbCrLf, "<br/>")
            End Set
        End Property
        Public Property MyFont() As Font
            Get
                Return MyBase.Font
            End Get
            Set(ByVal value As Font)
                MyBase.Font = value
            End Set
        End Property
    
    End Class
    I enter the text on the webBrowser setting the Texto property, where I replaces all vbcrlf with "<br/>".

    I wanted to replace a filename in the text, with a link to the filename this way:
    Code:
    "<A HREF=""javascript:window.open('file:///" & FileName & "'); void(0)"">" & FileName & "</A>"
    (I pass that text to the webbrowser)

    The problem is, At clicking in the link, it gives an error message box telling "Access denied".

    I have found a workaround in this page
    It advices:
    Quote Originally Posted by link
    Open up distributed COM configuration properties and
    choose the default security tab. Under Default Access Permissions you
    add 'Everyone' with Allow Access.
    But it looks like a bad hack. Is there a better way to do it?
    [Vb.NET 2008 (ex Express)]

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,870

    Re: Access denied in WebBrowser control

    JavaScript is only allowed to work in the domain in which it is loaded. That is why you receive the "Access denied" message. There is no way around this other than changing the security settings. But, doing that can open security holes to your machine through Internet Explorer.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Re: Access denied in WebBrowser control

    Quote Originally Posted by PeejAvery View Post
    JavaScript is only allowed to work in the domain in which it is loaded. That is why you receive the "Access denied" message. There is no way around this other than changing the security settings. But, doing that can open security holes to your machine through Internet Explorer.
    I did not tested it on vista, but I are 100% fearsome that this would really mess the things in Vista.

    some days ago, My boss Installed my program in a Vista Notebook, and I had a hell triyng to make it works.

    Vista "virtualized" my code, and keep it installed with older files, even after uninstalling the application.

    I uninstalled it, manually deleted the virtualized directories, reinstalled the application, and the older files where back!!. That is the dream of a virus programmer, and a hell for me.

    That and the infamy of the autorun.inf are, as I believe, the worst "features" of windows.
    [Vb.NET 2008 (ex Express)]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center